Examples: RemoveItem method
- This script removes the Subject item from a document.
Dim mainDoc As NotesDocument '...set value of mainDoc... Call mainDoc.RemoveItem( "Subject" ) Call mainDoc.Save( True, True )
- This script removes all file attachments from a document.
Dim doc As NotesDocument '...set value of doc... Call doc.RemoveItem( "$FILE" ) Call doc.Save( True, True )
- This sub lets you change the name of any item in a document. First
it uses ReplaceItemValue to put the contents of the item with the
old name into a new item with the new name. Then it uses RemoveItem
to remove the item with the old name.
Sub changeField _ ( doc As NotesDocument, oldName As String, _ newName As String ) If doc.HasItem( oldName ) Then Call doc.ReplaceItemValue( newName, _ doc.GetItemValue( oldName ) ) Call doc.RemoveItem( oldName ) Call doc.Save( False, True ) End If End Sub
For example, to change the name of the phone item to officePhone without losing the item's value, a script makes the following call:
Dim doc as NotesDocument '...set value of doc... Call changeField( doc, "phone", "officePhone" )
- This sub takes a collection of documents and removes the stored
form from each document. It uses RemoveItem to delete the five fields
that make up a stored form in a document: $TITLE, $INFO, $WINDOWTITLE,
$BODY and $ACTIONS.
Sub removeStoredForm_ ( collection As NotesDocumentCollection ) Dim doc As NotesDocument Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) If doc.HasItem( "$TITLE" ) Then formName = doc.GetItemValue( "$TITLE" ) Call doc.ReplaceItemValue( "Form", formName ) Call doc.RemoveItem( "$TITLE" ) Call doc.RemoveItem( "$INFO" ) Call doc.RemoveItem( "$WINDOWTITLE" ) Call doc.RemoveItem( "$BODY" ) Call doc.RemoveItem( "$ACTIONS" ) Call doc.Save( True, True ) End If Set doc = collection.GetNextDocument(doc) Wend End Sub