Share via


Add Method

Add method as it applies to the AddIns object.

Returns an AddIn object that represents an add-in added to the list of available add-ins.

expression.Add(FileName, Install)

expression Required. An expression that returns an AddIns object.

FileName    Required String. The path for the template or WLL.

Install    Optional Variant. True to install the add-in. False to add the add-in to the list of add-ins but not install it. The default value is True.

Remarks

Use the Installed property of an add-in to see whether it's already installed.

Add method as it applies to the AutoCorrectEntries object.

Returns an AutoCorrectEntry object that represents a plain-text AutoCorrect entry added to the list of available AutoCorrect entries.

expression.Add(Name, Value)

expression Required. An expression that returns an AutoCorrectEntries object.

Name    Required String. The text you want to have automatically replaced with the text specified by Value.

Value    Required String. The text you want to have automatically inserted whenever the text specified by Name is typed.

Remarks

Use the AddRichText method to create a formatted AutoCorrect entry.

Add method as it applies to the AutoTextEntries object.

Returns an AutoTextEntry object that represents an AutoText entry added to the list of available AutoText entries.

expression.Add(Name, Range)

expression Required. An expression that returns an AutoTextEntries object.

Name    Required String. The text that, when typed, initiates an AutoText entry.

Range    Required Range. A range of text that will be inserted whenever Name is typed.

Add method as it applies to the Bookmarks object.

Returns a Bookmark object that represents a bookmark added to a range.

expression.Add(Name, Range)

expression Required. An expression that returns a Bookmarks object.

Name   Required String. The name of the bookmark. The name cannot be more than one word.

Range   Optional Variant. The range of text marked by the bookmark. A bookmark can be set to a collapsed range (the insertion point).

Add method as it applies to the CaptionLabels object.

Returns a CaptionLabel object that represents a custom caption label.

expression.Add(Name)

expression Required. An expression that returns a CaptionLabels object.

Name   Required String. The name of the custom caption label.

Add method as it applies to the Cells object.

Returns a Cell object that represents a cell added to a table.

expression.Add(BeforeCell)

expression Required. An expression that returns a Cells object.

BeforeCell   Optional Variant. A Cell object that represents the cell that will appear immediately to the right of the new cell or cells.

Add method as it applies to the Columns object.

Returns a Column object that represents a column added to a table.

expression.Add(BeforeColumn)

expression Required. An expression that returns a Columns object.

BeforeColumn   Optional Variant. A Column object that represents the column that will appear immediately to the right of the new column.

Add method as it applies to the Comments object.

Returns a Comment object that represents a comment added to a range.

expression.Add(Range, Text)

expression Required. An expression that returns a Comments object.

Range   Required Range object. The range to have a comment added to it.

Text   Optional Variant. The text of the comment.

Add method as it applies to the CustomLabels object.

Adds a custom mailing label to the CustomLabels collection. Returns a CustomLabel object that represents the custom mailing label.

expression.Add(Name, DotMatrix)

expression Required. An expression that returns a CustomLabels object.

Name   Required String. The name for the custom mailing labels.

DotMatrix   Optional Variant. True to have the mailing labels printed on a dot-matrix printer.

Add method as it applies to the CustomProperties object.

Returns a CustomProperty object that represents s custom property added to a smart tag.

expression.Add(Name, Value)

expression Required. An expression that returns a CustomProperties object.

Name   Required String. The name of the custom smart tag property.

Value   Required String. The value of the custom smart tag property

Add method as it applies to the Dictionaries and HangulHanjaConversionDictionaries objects.

Returns a Dictionary object that represents a new custom spelling or conversion dictionary added to the collection of active custom spelling or conversion dictionaries. If a file with the name specified by FileName doesn't exist, Microsoft Word creates one.

expression.Add(FileName)

expression Required. An expression that returns one of the above objects.

FileName   Required String. The string name of the dictionary file. If no path is specified in the string, the proofing tools path is used.

Remarks

The Dictionaries collection includes only the active custom spelling dictionaries. Dictionary objects that are derived from the Languages collection don't have an Add method. These include the Dictionary objects returned by the ActiveSpellingDictionary, ActiveGrammarDictionary, ActiveThesaurusDictionary, and ActiveHyphenationDictionary properties.

Use the HangulHanjaDictionaries property to return the collection of custom conversion dictionaries. The HangulHanjaConversionDictionaries collection includes only the active custom conversion dictionaries.

For more information on using Microsoft Word with East Asian languages, see Word features for East Asian languages .

Add method as it applies to the Documents object.

Returns a Document object that represents a new, empty document added to the collection of open documents.

expression.Add(Template, NewTemplate, DocumentType, Visible)

expression Required. An expression that returns a Documents object.

Template   Optional Variant. The name of the template to be used for the new document. If this argument is omitted, the Normal template is used.

NewTemplate   Optional Variant. True to open the document as a template. The default value is False.

DocumentType   Optional Variant. Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.

Visible   Optional Variant. True to open the document in a visible window. If this value is False, Microsoft Word opens the document but sets the Visible property of the document window to False. The default value is True.

Add method as it applies to the Editors object.

Returns an Editor object that represents a new permission for a specified user to modify a range or selection within a document.

expression.Add(EditorID)

expression Required. An expression that returns one of the objects in the Applies To list.

WdEditorType

wdEditorType can be one of the following wdEditorType constants.

wdEditorCurrent   Represents the current user of the document.
wdEditorEditors   Represents the Editors group for documents that use Information Rights Management.
wdEditorEveryone   Represents all users who open a document.
wdEditorOwners   Represents the Owners group for documents that use Information Rights Management.

Add method as it applies to the EmailSignatureEntries object.

Returns an EmailSignatureEntry object that represents a new e-mail signature entry.

expression.Add(Name, Range)

expression Required. An expression that returns an EmailSignatureEntries object.

Name   Required String. The name of the e-mail entry.

Range   Required Range object. The range in the document that will be added as the signature.

Remarks

An e-mail signature is standard text that ends an e-mail message, such as your name and telephone number. Use the EmailSignatureEntries property to create and manage a collection of e-mail signatures that Microsoft Word will use when creating e-mail messages.

Add method as it applies to the Endnotes and Footnotes objects.

Returns an Endnote or Footnote object that represents an endnote or footnote added to a range.

expression.Add(Range, Reference, Text)

expression Required. An expression that returns one of the above objects.

Range   Required Range object. The range marked for the endnote or footnote. This can be a collapsed range.

Reference   Optional Variant. The text for the custom reference mark. If this argument is omitted, Microsoft Word inserts an automatically-numbered reference mark.

Text   Optional Variant. The text of the endnote or footnote.

Remarks

To specify a symbol for the Reference argument, use the syntax {FontNameCharNum}. FontName is the name of the font that contains the symbol. Names of decorative fonts appear in the Font box in the Symbol dialog box (Insert menu). CharNum is the sum of 31 and the number corresponding to the position of the symbol you want to insert, counting from left to right in the table of symbols. For example, to specify an omega symbol at position 56 in the table of symbols in the Symbol font, the argument would be "{Symbol 87}".

Add method as it applies to the Fields object.

Adds a Field object to the Fields collection. Returns the Field object at the specified range.

expression.Add(Range, Type, Text, PreserveFormatting)

expression Required. An expression that returns a Fields object.

Range   Required Range object. The range where you want to add the field. If the range isn't collapsed, the field replaces the range.

Type   Optional Variant. Can be any WdFieldType constant. For a list of valid constants, consult the Object Browser. The default value is wdFieldEmpty.

Text   Optional Variant. Additional text needed for the field. For example, if you want to specify a switch for the field, you would add it here.

PreserveFormatting   Optional Variant. True to have the formatting that's applied to the field preserved during updates.

Remarks

You cannot insert some fields (such as wdFieldOCX and wdFieldFormCheckBox) by using the Add method of the Fields collection. Instead, you must use specific methods such as the AddOLEControl method and the Add method for the FormFields collection.

Add method as it applies to the FirstLetterExceptions, OtherCorrectionsExceptions, and TwoInitialCapsExceptions objects.

Returns a FirstLetterException, OtherCorrectionsExceptions, or TwoInitialCapsExceptions object that represents a new exception added to the list of AutoCorrect exceptions.

expression.Add(Name)

expression Required. An expression that returns one of the above objects.

Name   Required String. The word with two initial capital letters that you want Microsoft Word to overlook (FirstLetterExceptions object), the abbreviation that you don't want Word to follow with a capital letter (TwoInitialCapsExceptions object), or any other word you want Word to overlook (OtherCorrectionsExceptions object).

Remarks

If the TwoInitialCapsAutoAdd property is True, words are automatically added to the list of initial-capital exceptions. If the FirstLetterAutoAdd property is True, abbreviations are automatically added to the list of first-letter exceptions. If the OtherCorrectionsAutoAdd property is True, words are automatically added to the list of other corrections exceptions.

Add method as it applies to the FormFields object.

Returns a FormField object that represents a new form field added at a range.

expression.Add(Range, Type)

expression Required. An expression that returns a FormFields object.

Range   Required Range object. The range where you want to add the form field. If the range isn't collapsed, the form field replaces the range.

WdFieldType

WdFieldType can be one of these WdFieldType constants.
wdFieldAddin
wdFieldAdvance
wdFieldAsk
wdFieldAuthor
wdFieldAutoNum
wdFieldAutoNumLegal
wdFieldAutoNumOutline
wdFieldAutoText
wdFieldAutoTextList
wdFieldBarCode
wdFieldComments
wdFieldCompare
wdFieldCreateDate
wdFieldData
wdFieldDatabase
wdFieldDate
wdFieldDDE *
wdFieldDDEAuto *
wdFieldDocProperty
wdFieldDocVariable
wdFieldEditTime
wdFieldEmbed
wdFieldEmpty
wdFieldExpression
wdFieldFileName
wdFieldFileSize
wdFieldFillIn
wdFieldFootnoteRef
wdFieldFormCheckBox
wdFieldFormDropDown
wdFieldFormTextInput
wdFieldFormula
wdFieldGlossary
wdFieldGoToButton
wdFieldHTMLActiveX
wdFieldHyperlink
wdFieldIf
wdFieldImport
wdFieldInclude
wdFieldIncludePicture
wdFieldIncludeText
wdFieldIndex
wdFieldIndexEntry
wdFieldInfo
wdFieldKeyWord
wdFieldLastSavedBy
wdFieldLink
wdFieldListNum
wdFieldMacroButton
wdFieldMergeField
wdFieldMergeRec
wdFieldMergeSeq
wdFieldNext
wdFieldNextIf
wdFieldNoteRef
wdFieldNumChars
wdFieldNumPages
wdFieldNumWords
wdFieldOCX
wdFieldPage
wdFieldPageRef
wdFieldPrint
wdFieldPrintDate
wdFieldPrivate
wdFieldQuote
wdFieldRef
wdFieldRefDoc
wdFieldRevisionNum
wdFieldSaveDate
wdFieldSection
wdFieldSectionPages
wdFieldSequence
wdFieldSet
wdFieldSkipIf
wdFieldStyleRef
wdFieldSubject
wdFieldSubscriber
wdFieldSymbol
wdFieldTemplate
wdFieldTime
wdFieldTitle
wdFieldTOA
wdFieldTOAEntry
wdFieldTOC
wdFieldTOCEntry
wdFieldUserAddress
wdFieldUserInitials
wdFieldUserName

Security  Dynamic data exchange (DDE) is an older technology that is not secure. If possible, use a more secure alternative to DDE, such as object linking and embedding (OLE).

Add method as it applies to the Frames object.

Returns a Frame object that represents a new frame added to a range, selection, or document.

expression.Add(Range)

expression Required. An expression that returns a Frames object.

Range   Required Range object. The range that you want the frame to surround.

Add method as it applies to the HangulAndAlphabetExceptions object.

Returns a HangulAndAlphabetException object that represents a new exception to the list of AutoCorrect exceptions.

expression.Add(Name)

expression Required. An expression that returns a HangulAndAlphabetExceptions object.

Name   Required String. The word that you don't want Microsoft Word to correct automatically.

Remarks

If the HangulAndAlphabetAutoAdd property is set to True, words are automatically added to the list of hangul and alphabet AutoCorrect exceptions.

For more information on using Word with East Asian languages, see Word features for East Asian languages .

Add method as it applies to the HeadingStyles object.

Returns a HeadingStyle object that represents a new heading style added to a document. The new heading style will be included whenever you compile a table of contents or table of figures.

expression.Add(Style, Level)

expression Required. An expression that returns a HeadingStyles object.

Style   Required Variant. The style you want to add. You can specify this argument by using either the string name for the style or a Style object.

Level   Required Integer. A number that represents the level of the heading.

Add method as it applies to the HTMLDivisions object.

Returns an HTMLDivision object that represents a new HTML division added to a Web document.

expression.Add(Range)

expression Required. An expression that returns an HTMLDivisions object.

Range   Optional Variant. An existing HTML division around which to place the new HTML division.

Returns a Hyperlink object that represents a new hyperlink added to a range, selection, or document.

expression.Add(Anchor, Address, SubAddress, ScreenTip, TextToDisplay, Target)

expression Required. An expression that returns a Hyperlinks object.

Anchor   Required Object. The text or graphic that you want turned into a hyperlink.

Address   Optional Variant. The address for the specified link. The address can be an e-mail address, an Internet address, or a file name. Note that Microsoft Word doesn't check the accuracy of the address.

SubAddress   Optional Variant. The name of a location within the destination file, such as a bookmark, named range, or slide number.

ScreenTip   Optional Variant. The text that appears as a ScreenTip when the mouse pointer is positioned over the specified hyperlink. The default value is Address.

TextToDisplay   Optional Variant. The display text of the specified hyperlink. The value of this argument replaces the text or graphic specified by Anchor.

Target   Optional Variant. The name of the frame or window in which you want to load the specified hyperlink.

Add method as it applies to the Indexes object.

Returns an Index object that represents a new index added to a document.

expression.Add(Range, HeadingSeparator, RightAlignPageNumbers, Type, NumberOfColumns, AccentedLetters, SortBy, IndexLanguage)

expression Required. An expression that returns an Indexes object.

Range   Required Range object. The range where you want the index to appear. The index replaces the range, if the range isn't collapsed.

HeadingSeparator   Optional Variant.The text between alphabetic groups (entries that start with the same letter) in the index. Can be one of the following WdHeadingSeparator constants: wdHeadingSeparatorBlankLine, wdHeadingSeparatorLetter, wdHeadingSeparatorLetterFull, wdHeadingSeparatorLetterLow, or wdHeadingSeparatorNone.

RightAlignPageNumbers   Optional Variant. True to align page numbers with the right margin.

Type   Optional Variant. Specifies whether subentries are on the same line (run-in) as the main entry or on a separate line (indented) from the main entry. Can be either of the following WdIndexType constants: wdIndexIndent or wdIndexRunin.

NumberOfColumns   Optional Variant. The number of columns for each page of the index. Specifying 0 (zero) sets the number of columns in the index to the same number as in the document.

AccentedLetters   Optional Variant. True to include separate headings for accented letters in the index (for example, words that begin with "À" and words that begin with "A" are listed under separate headings).

SortBy   Optional Variant. The sorting criteria to be used for the specified index. Can be either of the following WdIndexSortBy constants: wdIndexSortByStroke or wdIndexSortBySyllable.

IndexLanguage   Optional Variant. The sorting language to be used for the specified index. Can be any of the WdLanguageID constants. For the list of valid WdLanguageID constants, see the Object Browser in the Visual Basic Editor.

Remarks

An index is built from Index Entry (XE) fields in a document. Use the MarkEntry method to mark index entries to be included in an index.

Add method as it applies to the KeyBindings object.

Returns a KeyBinding object that represents a new shortcut key for a macro, built-in command, font, AutoText entry, style, or symbol.

expression.Add(KeyCategory, Command, KeyCode, KeyCode2, CommandParameter)

expression Required. An expression that returns a KeyBindings object.

WdKeyCategory

WdKeyCategory can be one of these WdKeyCategory constants.
wdKeyCategoryAutoText
wdKeyCategoryCommand
wdKeyCategoryDisable
wdKeyCategoryFont
wdKeyCategoryMacro
wdKeyCategoryNil
wdKeyCategoryPrefix
wdKeyCategoryStyle
wdKeyCategorySymbol

Command   Required String.The command that the specified key combination executes.

KeyCode   Required Long. A key you specify by using one of the WdKey constants.

KeyCode2   Optional Variant. A second key you specify by using one of the WdKey constants.

CommandParameter   Optional Variant. Additional text, if any, required for the command specified by Command. For details, see the Remarks section below.

Remarks

You can use the BuildKeyCode method to create the KeyCode or KeyCode2 argument.

In the following table, the left-hand column contains commands that require a command value, and the right-hand column describes what you must do to specify CommandParameter for each of these commands. (The equivalent action in the Customize Keyboard dialog box (Tools menu) to specifying CommandParameter is selecting an item in the list box that appears when you select one of the following commands in the Commands box.)

If Command is set to CommandParameter must be
Borders, Color, or Shading A number — specified as text — corresponding to the position of the setting selected in the list box that contains values, where 0 (zero) is the first item, 1 is the second item, and so on
Columns A number between 1 and 45 — specified as text — corresponding to the number of columns you want to apply
Condensed A text measurement between 0.1 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch)
Expanded A text measurement between 0.1 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch)
FileOpenFile The path and file name of the file to be opened. If the path isn't specified, the current folder is used.
Font Size A positive text measurement, specified in 0.5-point increments (72 points = 1 inch)
Lowered, Raised A text measurement between 1 point and 64 points, specified in 0.5-point increments (72 points = 1 inch)
Symbol A string created by concatenating a Chr() instruction and the name of a symbol font (for example, Chr(167) & "Symbol")

Add method as it applies to the ListEntries object.

Returns a ListEntry object that represents an item added to a drop-down form field.

expression.Add(Name, Index)

expression Required. An expression that returns a ListEntries object.

Name   Required String. The name of the drop-down form field item.

Index   Optional Variant. A number that represents the position of the item in the list.

Add method as it applies to the ListTemplates object.

Returns a ListTemplate object that represents a new list template.

expression.Add(OutlineNumbered, Name)

expression Required. An expression that returns a ListTemplates object.

OutlineNumbered   Optional Variant. True to apply outline numbering to the new list template.

Name   Optional Variant. An optional name used for linking the list template to a LISTNUM field. You cannot use this name to index the list template in the collection.

Remarks

You cannot use the Add method on ListTemplates objects returned from a ListGallery object. You can, however, modify the existing list templates in the galleries.

Add method as it applies to the MailMergeFields object.

Returns a MailMergeField object that represents a mail merge field added to the data source document.

expression.Add(Range, Name)

expression Required. An expression that returns a MailMergeFields object.

Range   Required Range object. The range where you want the field to appear. This field replaces the range, if the range isn't collapsed.

Name   Required String. The name of the field.

Add method as it applies to the PageNumbers object.

Returns a PageNumber object that represents page numbers added to a header or footer in a section.

expression.Add(PageNumberAlignment, FirstPage)

expression Required. An expression that returns a PageNumbers object.

WdPageNumberAlignment

wdAlignPageNumberCenter
wdAlignPageNumberInside
wdAlignPageNumberLeft
wdAlignPageNumberOutside
wdAlignPageNumberRight

FirstPage   Optional Variant. False to make the first-page header and the first-page footer different from the headers and footers on all subsequent pages in the document. If FirstPage is set to False, a page number isn't added to the first page. If this argument is omitted, the setting is controlled by the DifferentFirstPageHeaderFooter property.

Remarks

If the LinkToPrevious property for the HeaderFooter object is set to True, the page numbers will continue sequentially from one section to next throughout the document.

Add method as it applies to the Panes object.

Returns a Pane object that represents a new pane to a window.

expression.Add(SplitVertical)

expression Required. An expression that returns a Panes object.

SplitVertical   Optional Variant. A number that represents the percentage of the window, from top to bottom, you want to appear above the split.

Remarks

This method will fail if it's applied to a window that's already been split.

Add method as it applies to the Paragraphs object.

Returns a Paragraph object that represents a new, blank paragraph added to a document.

expression.Add(Range)

expression Required. An expression that returns a Paragraphs object.

Range   Optional Variant. The range before which you want the new paragraph to be added. The new paragraph doesn't replace the range.

Remarks

If Range isn't specified, the new paragraph is added after the selection or range or at the end of the document, depending on expression.

Add method as it applies to the RecentFiles object.

Returns a RecentFile object that represents a file added to the list of recently used files.

expression.Add(Document, ReadOnly)

expression Required. An expression that returns a RecentFile object.

Document   Required Variant. The document you want to add to the list of recently used files. You can specify this argument by using either the string name for the document or a Document object.

ReadOnly   Optional Variant. True to make the document read-only.

Add method as it applies to the Rows object.

Returns a Row object that represents a row added to a table.

expression.Add(BeforeRow)

expression Required. An expression that returns a Rows object.

BeforeRow   Optional Variant. A Row object that represents the row that will appear immediately below the new row.

Add method as it applies to the Sections object.

Returns a Section object that represents a new section added to a document.

expression.Add(Range, Start)

expression Required. An expression that returns a Sections object.

Range   Optional Variant. The range before which you want to insert the section break. If this argument is omitted, the section break is inserted at the end of the document.

Start   Optional Variant. The type of section break you want to add. Can be one of the following WdSectionStart constants: wdSectionContinuous, wdSectionEvenPage, wdSectionNewColumn, wdSectionNewPage, or wdSectionOddPage. If this argument is omitted, a Next Page section break is added.

Add method as it applies to the SmartTags object.

Returns a SmartTag object that represents a new smart tag added to a document.

expression.Add(Name, Range, Properties)

expression Required. An expression that returns a SmartTags object.

Name   Required String. The name of the smart tag.

Range   Optional Variant. The range to which to apply the smart tag.

Properties   Optional Variant. Properties that apply to the smart tag.

Add method as it applies to the Styles object.

Returns a Style object that represents a new user-defined style added to the list of styles.

expression.Add(Name, Type)

expression Required. An expression that returns a Styles object.

Name   Required String. The string name for the new style.

Type   Optional Variant. The style type of the new style. Can be one of the following WdStyleType constants: wdStyleTypeParagraph, wdStyleTypeCharacter, wdStyleTypeList, or wdStyleTypeTable.

Add method as it applies to the StyleSheets object.

Returns a StyleSheet object that represents a new style sheet added to a Web document.

expression.Add(FileName, LinkType, Title, Precedence)

expression Required. An expression that returns a StyleSheets object.

FileName   Required String. The path and file name of the cascading style sheet.

WdStyleSheetLinkType

WdStyleSheetLinkType can be one of these WdStyleSheetLinkType constants.
wdStyleSheetLinkTypeImported
wdStyleSheetLinkTypeLinkeddefault

Title   Required String. The name of the style sheet.

WdStyleSheetPrecedence

WdStyleSheetPrecedence can be one of these WdStyleSheetPrecedence constants.
wdStyleSheetPrecedenceHigher
wdStyleSheetPrecedenceHighestdefault
wdStyleSheetPrecedenceLower
wdStyleSheetPrecedenceLowest

Add method as it applies to the Tables object.

Returns a Table object that represents a new, blank table added to a document.

expression.Add(Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior)

expression Required. An expression that returns a Tables object.

Range   Required Range object. The range where you want the table to appear. The table replaces the range, if the range isn't collapsed.

NumRows   Required Long. The number of rows you want to include in the table.

NumColumns   Required Long. The number of columns you want to include in the table.

DefaultTableBehavior   Optional Variant. Sets a value that specifies whether Microsoft Word automatically resizes cells in tables to fit the cells' contents (AutoFit). Can be either of the following constants: wdWord8TableBehavior (AutoFit disabled) or wdWord9TableBehavior (AutoFit enabled). The default constant is wdWord8TableBehavior.

AutoFitBehavior   Optional Variant. Sets the AutoFit rules for how Word sizes tables. Can be one of the following WdAutoFitBehavior constants: wdAutoFitContent, wdAutoFitFixed, or wdAutoFitWindow. If DefaultTableBehavior is set to wdWord8TableBehavior, this argument is ignored.

Add method as it applies to the TablesOfAuthorities object.

Returns a TableOfAuthorities object that represents a table of authorities added to a document.

expression.Add(Range, Category, Bookmark, Passim, KeepEntryFormatting, Separator, IncludeSequenceName, EntrySeparator, PageRangeSeparator, IncludeCategoryHeader, PageNumberSeparator)

expression Required. An expression that returns a TableOfAuthorities object.

Range   Required Range object. The range where you want the table of authorities to appear. The table of authorities replaces the range, if the range isn't collapsed.

Category   Optional Variant. The category of entries you want to include in the table of authorities. Corresponds to the \c switch for a Table of Authorities (TOA) field. Values 0 through 16 correspond to the items listed in the Category box on the Table of Authorities tab in the Index and Tables dialog box (Reference command, Insert menu). The default value is 1.

Bookmark   Optional Variant. The string name of the bookmark from which you want to collect entries for the table of authorities. If Bookmark is specified, the entries are collected only from the portion of the document marked by the bookmark. Corresponds to the \b switch for a Table of Authorities (TOA) field.

Passim   Optional Variant. True to replace five or more page references to the same authority with Passim in the table of authorities. Corresponds to the \p switch for a Table of Authorities (TOA) field. If this argument is omitted, Passim is assumed to be False.

KeepEntryFormatting   Optional Variant. True to apply formatting from table of authorities entries to the entries in the table of authorities. Corresponds to the \f switch for a Table of Authorities (TOA) field. If this argument is omitted, KeepEntryFormatting is assumed to be True.

Separator   Optional Variant. The characters (up to five) between each sequence number and its page number in the table of authorities. Corresponds to the \d switch for a Table of Authorities (TOA) field. If argument is omitted, a hyphen (-) is used.

IncludeSequenceName   Optional Variant. A string that specifies the Sequence (SEQ) field identifier for the table of authorities. Corresponds to the \s switch for a Table of Authorities (TOA) field.

EntrySeparator   Optional Variant. The characters (up to five) that separate each entry and its page number in the table of authorities. Corresponds to the \e switch for a Table of Authorities (TOA) field. If this argument is omitted, no separator is used.

PageRangeSeparator   Optional Variant. The characters (up to five) that separate the beginning and ending page numbers in each page range the table of authorities. Corresponds to the \g switch for a Table of Authorities (TOA) field. If this argument is omitted, an en dash is used.

IncludeCategoryHeader   Optional Variant. True to have the category name for each group of entries appear in the table of authorities (for example, Cases). Corresponds to the \h switch for a Table of Authorities (TOA) field. If this argument is omitted, IncludeCategoryHeader is assumed to be True.

PageNumberSeparator   Optional Variant. The characters (up to five) that separate individual page numbers within page references in the table of authorities. Corresponds to the \l switch for a Table of Authorities (TOA) field. If this argument is omitted, a comma and a space are used.

Remarks

A table of authorities is built from Table of Authorities Entry (TA) fields in a document. Use the MarkCitation method to mark citations to be included in the table of authorities.

Add method as it applies to the TablesOfContents object.

Returns a TableOfContents object that represents a table of contents added to a document.

expression.Add(Range, UseHeadingStyles, UpperHeadingLevel, LowerHeadingLevel, UseFields, TableID, RightAlignPageNumbers, IncludePageNumbers, AddedStyles, UseHyperlinks, HidePageNumbersInWeb, UseOutlineLevels)

expression Required. An expression that returns a TableOfContents object.

Range   Required Range object. The range where you want the table of contents to appear. The table of contents replaces the range, if the range isn't collapsed.

UseHeadingStyles   Optional Variant. True to use built-in heading styles to create the table of contents. The default value is True.

UpperHeadingLevel   Optional Variant. The starting heading level for the table of contents. Corresponds to the starting value used with the \o switch for a Table of Contents (TOC) field. The default value is 1.

LowerHeadingLevel   Optional Variant. The ending heading level for the table of contents. Corresponds to the ending value used with the \o switch for a Table of Contents (TOC) field. The default value is 9.

UseFields   Optional Variant. True if Table of Contents Entry (TC) fields are used to create the table of contents. Use the MarkEntry method to mark entries to be included in the table of contents. The default value is False.

TableID   Optional Variant. A one-letter identifier that's used to build a table of contents from TC fields. Corresponds to the \f switch for a Table of Contents (TOC) field. For example, "T" builds a table of contents from TC fields using the table identifier T. If this argument is omitted, TC fields aren't used.

RightAlignPageNumbers   Optional Variant. True if page numbers in the table of contents are aligned with the right margin. The default value is True.

IncludePageNumbers   Optional Variant. True to include page numbers in the table of contents. The default value is True.

AddedStyles   Optional Variant. The string name for additional styles used to compile the table of contents (styles other than the Heading 1 – Heading 9 styles). Use the Add method of a HeadingStyles object to create new heading styles.

UseHyperlinks   Optional Variant. True if entries in a table of contents should be formatted as hyperlinks when the document is being publishing to the Web. The default value is True.

HidePageNumbersInWeb   Optional Variant. True if page numbers in a table of contents should be hidden when the document is being publishing to the Web. The default value is True.

UseOutlineLevels   Optional Variant. True to use outline levels to create the table of contents. The default is False.

Add method as it applies to the TablesOfFigures object.

Returns a TableOfFigures object that represents a table of figures added to a document.

expression.Add(Range, Caption, IncludeLabel, UseHeadingStyles, UpperHeadingLevel, LowerHeadingLevel, UseFields, TableID, RightAlignPageNumbers, IncludePageNumbers, AddedStyles, UseHyperlinks, HidePageNumbersInWeb)

expression Required. An expression that returns a TableOfFigures object.

Range   Required Range object. The range where you want the table of figures to appear.

Caption   Optional Variant. The label that identifies the items you want to include in the table of figures. Corresponds to the \c switch for a Table of Contents (TOC) field. The default value is "Figure."

IncludeLabel   Optional Variant. True to include the caption label and caption number in the table of figures. The default value is True.

UseHeadingStyles   Optional Variant. True to use built-in heading styles to create the table of figures. The default value is False.

UpperHeadingLevel   Optional Variant. The starting heading level for the table of figures, if UseHeadingStyles is set to True. Corresponds to the starting value used with the \o switch for a Table of Contents (TOC) field. The default value is 1.

LowerHeadingLevel   Optional Variant. The ending heading level for the table of figures, if UseHeadingStyles is set to True. Corresponds to the ending value used with the \o switch for a Table of Contents (TOC) field. The default value is 9.

UseFields   Optional Variant. True to use Table of Contents Entry (TC) fields to create the table of figures. Use the MarkEntry method to mark entries you want to include in the table of figures. The default value is False.

TableID   Optional Variant. A one-letter identifier that's used to build a table of figures from Table of Contents Entry (TC) fields. Corresponds to the \f switch for a Table of Contents (TOC) field. For example, "i" builds a table of figures for an illustration.

RightAlignPageNumbers   Optional Variant. True align page numbers with the right margin in the table of figures. The default value is True.

IncludePageNumbers   Optional Variant. True if page numbers are included in the table of figures. The default value is True.

AddedStyles   Optional Variant. The string name for additional styles used to compile the table of figures (styles other than the Heading 1 – Heading 9 styles).

UseHyperlinks   Optional Variant. True if entries in a table of figures should be formatted as hyperlinks when publishing to the Web. The default value is True.

HidePageNumbersInWeb   Optional Variant. True if page numbers in a table of figures should be hidden when publishing to the Web. The default value is True.

Add method as it applies to the TabStops object.

Returns a TabStop object that represents a custom tab stop added to a document.

expression.Add(Position, Alignment, Leader)

expression Required. An expression that returns a TabStops object.

Position   Required Single. The position of the tab stop (in points) relative to the left margin.

Alignment   Optional Variant. The alignment of the tab stop. Can be one of the following WdTabAlignment constants: wdAlignTabBar, wdAlignTabCenter, wdAlignTabDecimal, wdAlignTabLeft, wdAlignTabList, or wdAlignTabRight. If this argument is omitted, wdAlignTabLeft is used.

Leader   Optional Variant. The type of leader for the tab stop. Can be one of the following WdTabLeader constants: wdTabLeaderDashes, wdTabLeaderDots, wdTabLeaderHeavy, wdTabLeaderLines, wdTabLeaderMiddleDot, or wdTabLeaderSpaces. If this argument is omitted, wdTabLeaderSpaces is used.

Add method as it applies to the TextColumns object.

Returns a TextColumn object that represents a new text column added to a section or document.

expression.Add(Width, Spacing, EvenlySpaced)

expression Required. An expression that returns a TextColumns object.

Width   Optional Variant. The width of the new text column in the document, in points.

Spacing   Optional Variant. The spacing between the text columns in the document, in points.

EvenlySpaced   Optional Variant. True to evenly space all the text columns be in the document.

Add method as it applies to the Variables object.

Returns a Variable object that represents a variable added to a document.

expression.Add(Name, Value)

expression Required. An expression that returns a Variables object.

Name   Required String. The name of the document variable.

Value   Optional Variant. The value for the document variable.

Remarks

Document variables are invisible to the user unless a DOCVARIABLE field is inserted with the appropriate variable name. If you try to add a variable with a name that already exists in the Variables collection, an error occurs. To avoid this error, you can enumerate the collection before adding a new variable to it.

Add method as it applies to the Windows object.

Returns a Window object that represents a new window of a document.

expression.Add(Window)

expression Required. An expression that returns a Windows object.

Window   Optional Variant. The Window object you want to open another window for. If this argument is omitted, a new window is opened for the active document.

Remarks

A colon (:) and a number appear in the window caption when more than one window is open for the document.

Add method as it applies to the XMLNamespaces object.

Returns an ****

Visit XMLNamespace

object that represents a schema that is added to the Schema Library and made available to users in Microsoft Word.

expression.Add(Path, NamespaceURI, Alias, InstallForAllUsers)

expression Required. An expression that returns an Application object.

Path    Required String. The path and file name of the schema. This may be a local file path, a network path, or an Internet address.

NamespaceURI    Optional String. The namespace Uniform Resource Indicator as specified in the schema. The NamespaceURI parameter is case-sensitive and must be spelled exactly as specified in schema.

Alias    Optional String. The name of the schema as it appears on the Schemas tab in the Templates and Add-ins dialog box.

InstallForAllUsers    Optional Boolean. True if all users that log on to a computer can access and use the new schema. The default is False.

Add method as it applies to the XMLNodes object.

Returns an ****

Visit XMLNode

object that represents a newly added element.

expression.Add(Name, Namespace, Range)

expression Required. An expression that returns an XMLNodes object.

Name    Required String. The name of the element in the XML schema designated in the Namespace parameter. Because XML is case-sensitive, the spelling of the element specified in the Name parameter must be exactly as it appears in the schema. If the String does not match any of the element names in the schema specified in the Namespace parameter, an error is displayed.

Namespace    Required String. The name of the schema as defined in the schema. The Namespace parameter is case-sensitive and must be spelled exactly as it appears in the schema. If the specified namespace cannot be found in any of the schemas attached to the document, an error is displayed.

Range    Optional Range. The range to which you want to apply the element. The default is to place the element tags at the insertion point or around the selection if a text is selected.

Add method as it applies to the XMLSchemaReferences object.

Returns an ****

Visit XMLSchemaReference

that represents a schema applied to a document.

expression.Add(NamespaceURI, Alias, FileName, InstallForAllUsers)

expression Required. An expression that returns an XMLSchemaReferences object.

NamespaceURI    Optional String. The name of the schema as defined in the schema. The Namespace parameter is case-sensitive and must be spelled exactly as it appears in the schema. If the specified namespace cannot be found in any of the schemas attached to the document, an error is displayed.

Alias    Optional String. The name of the schema as it appears on the Schemas tab in the Templates and Add-ins dialog box.

FileName    Optional String. The path and file name of the schema. This may be a local file path, a network path, or an Internet address.

InstallForAllUsers    Optional Boolean. True if all users that log on to a computer can access and use the new schema. The default is False.

Add method as it applies to the XSLTransforms object.

Returns an ****

Visit XSLTransform

object that represents an Extensible Stylesheet Language Transformation (XSLT) added to the collection of XSLTs for a specified schema.

expression.Add(Location, Alias, InstallForAllUsers)

expression Required. An expression that returns an XSLTransforms collection.

Location    Required String. The path and file name of the XSLT. This may be a local file path, a network path, or an Internet address.

Alias    Optional String. The name of the XSLT as it appears in the Schema Library.

InstallForAllUsers    Optional Boolean. True if all users that log on to a computer can access and use the new schema. The default is False.

Examples

As it applies to the AddIns object.

This example installs a template named MyFax.dot and adds it to the list of add-ins in the Templates and Add-ins dialog box.

Sub AddTemplate()
    ' For this example to work correctly, verify that the
    ' path is correct and the file exists.

    AddIns.Add FileName:="C:\Program Files\Microsoft Office" _
        & "\Templates\Letters & Faxes\MyFax.dot", Install:=True
End Sub

As it applies to the AutoCorrectEntries object.

This example adds a plain-text AutoCorrect entry for a common misspelling of the word their.

AutoCorrect.Entries.Add Name:="thier", Value:="their"

As it applies to the AutoTextEntries object.

This example adds an AutoText entry named Sample Text that contains the text in the selection. This example assumes you have text selected in the active document.

Sub AutoTxt()
    NormalTemplate.AutoTextEntries.Add Name:="Sample Text", _
        Range:=Selection.Range
End Sub

As it applies to the Bookmarks object.

This example adds a bookmark named myplace to the selection in the active document.

Sub BMark()
    '  Select some text in the active document prior
    '  to execution.
    ActiveDocument.Bookmarks.Add _
        Name:="myplace", Range:=Selection.Range
End Sub

This example adds a bookmark named mark at the insertion point.

Sub Mark()
    ActiveDocument.Bookmarks.Add Name:="mark"
End Sub

This example adds a bookmark named third_para to the third paragraph in Letter.doc, and then it displays all the bookmarks for the document in the active window.

Sub ThirdPara()
    Dim myDoc As Document

    '  To best illustrate this example,
    '  Letter.doc must be opened, not active,
    '  and contain more than 3 paragraphs.
    Set myDoc = Documents("Letter.doc")
    myDoc.Bookmarks.Add Name:="third_para", _
        Range:=myDoc.Paragraphs(3).Range
    myDoc.ActiveWindow.View.ShowBookmarks = True
End Sub

As it applies to the CaptionLabels object.

This example adds a custom caption label named Demo Slide. To verify that the custom label is added, view the Label combo box in the Caption dialog box, accessed from the Reference item on the Insert menu.

Sub CapLbl()
    CaptionLabels.Add Name:="Demo Slide"
End Sub

As it applies to the Columns object.

This example creates a table with two columns and two rows in the active document and then adds another column before the first column. The width of the new column is set at 1.5 inches.

Sub AddATable()
    Dim myTable As Table
    Dim newCol As Column

    Set myTable = ActiveDocument.Tables.Add(Selection.Range, 2, 2)
    Set newCol = myTable.Columns.Add(BeforeColumn:=myTable.Columns(1))
    newCol.SetWidth ColumnWidth:=InchesToPoints(1.5), _
        RulerStyle:=wdAdjustNone
End Sub

As it applies to the Comments object.

This example adds a comment at the insertion point.

Sub AddComment()
    Selection.Collapse Direction:=wdCollapseEnd
    ActiveDocument.Comments.Add _
        Range:=Selection.Range, Text:="review this"
End Sub

This example adds a comment to the third paragraph in the active document.

Sub Comment3rd()
    Dim myRange As Range

    Set myRange = ActiveDocument.Paragraphs(3).Range
    ActiveDocument.Comments.Add Range:=myRange, _
        Text:="original third paragraph"
End Sub

As it applies to the CustomLabels object.

This example adds a custom mailing label named Return Address, sets the page size, and then creates a page of these labels.

Sub ReturnAddrLabel()
    Dim ml As CustomLabel
    Dim addr As String

    Set ml = Application.MailingLabel.CustomLabels _
        .Add(Name:="Return Address", DotMatrix:=False)
    ml.PageSize = wdCustomLabelLetter
    addr = "Dave Edson" & vbCr & "123 Skye St." & vbCr _
        & "Our Town, WA  98004"
    Application.MailingLabel.CreateNewDocument _
        Name:="Return Address", Address:=addr, ExtractAddress:=False
End Sub

As it applies to the Dictionaries and HangulHanjaConversionDictionaries objects.

This example removes all dictionaries from the list of custom spelling dictionaries and creates a new custom dictionary file. The new dictionary is assigned to be the active custom dictionary, to which new words are automatically added.

With CustomDictionaries
    .ClearAll
    .Add FileName:="c:\My Documents\MyCustom.dic"
    .ActiveCustomDictionary = CustomDictionaries(1)
End With

This example creates a new custom dictionary and assigns it to a variable. The new custom dictionary is then set to be used for text that's marked as French Canadian. Note that to run a spelling check for another language, you must have installed the proofing tools for that language.

Sub FrCanDic()
    Dim dicFrenchCan As Dictionary

    Set dicFrenchCan = CustomDictionaries.Add(FileName:="FrenchCanadian.dic")
    With dicFrenchCan
        .LanguageSpecific = True
        .LanguageID = wdFrenchCanadian
    End With
End Sub

This example removes all dictionaries from the list of custom conversion dictionaries and creates a new custom dictionary file. The new dictionary is assigned to be the active custom dictionary, to which new words are automatically added.

With HangulHanjaDictionaries
    .ClearAll
    .Add FileName:="C:\My Documents\MyCustom.hhd"
    .ActiveCustomDictionary = CustomDictionaries(1)
End With

As it applies to the Documents object.

This example creates a new document based on the Normal template.

Documents.Add

This example creates a new document based on the Professional Memo template.

Documents.Add Template:="C:\Program Files\Microsoft Office" _
    & "\Templates\Memos\Professional Memo.dot"

This example creates and opens a new template, using the template attached to the active document as a model.

tmpName = ActiveDocument.AttachedTemplate.FullName
Documents.Add Template:=tmpName, NewTemplate:=True

As it applies to the Editors object.

The following example gives editing permissions for the selected text to the current user.

Dim objEditor As Editor

Set objEditor = Selection.Editors.Add(wdEditorCurrent)

As it applies to the EmailSignatureEntries objects.

This example adds an automatically numbered footnote at the end of the selection.

Sub NewSignature()
    Application.EmailOptions.EmailSignature _
        .EmailSignatureEntries.Add _
        Name:=ActiveDocument.BuiltInDocumentProperties("Author"), _
        Range:=Selection.Range
End Sub

As it applies to the Endnotes and Footnotes objects.

This example adds an automatically-numbered footnote at the end of the selection.

ActiveDocument.Footnotes.Add Range:= Selection.Range , _
    Text:= "The Willow Tree, (Lone Creek Press, 1996)."

This example adds an endnote to the third paragraph in the active document

Set myRange = ActiveDocument.Paragraphs(3).Range
ActiveDocument.Endnotes.Add Range:=myRange, _
    Text:= "Ibid., 314."

This example adds a footnote that uses a custom symbol for the reference mark.

ActiveDocument.Footnotes.Add Range:= Selection.Range , _
    Text:= "More information in the full report.", _
    Reference:= "{Symbol -3998}"

As it applies to the Fields object.

This example inserts a USERNAME field at the beginning of the selection.

Selection.Collapse Direction:=wdCollapseStart
Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
    Type:=wdFieldUserName)

This example inserts a LISTNUM field at the end of the selection. The starting switch is set to begin at 3.

Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.Fields.Add Range:=Selection.Range, _
    Type:=wdFieldListNum, Text:="\s 3"

This example inserts a DATE field at the beginning of the selection and then displays the result.

Selection.Collapse Direction:=wdCollapseStart
Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
    Type:=wdFieldDate)
MsgBox myField.Result

As it applies to the FirstLetterExceptions, OtherCorrectionsExceptions, and TwoInitialCapsExceptions objects.

This example adds the abbreviation addr. to the list of first-letter exceptions.

AutoCorrect.FirstLetterExceptions.Add Name:="addr."

This example adds MSOffice to the list of initial-capital exceptions.

AutoCorrect.TwoInitialCapsExceptions.Add Name:="MSOffice"

This example adds myCompany to the list of other corrections exceptions.

AutoCorrect.OtherCorrectionsExceptions.Add Name:="myCompany"

As it applies to the FormFields object.

This example adds a check box at the end of the selection, gives it a name, and then selects it.

Selection.Collapse Direction:=wdCollapseEnd
Set ffield = ActiveDocument.FormFields _
    .Add(Range:=Selection.Range, Type:=wdFieldFormCheckBox)
With ffield
    .Name = "Check_Box_1"
    .CheckBox.Value = True
End With

As it applies to the Frames object.

This example adds a frame around the selection.

ActiveDocument.Frames.Add Range:=Selection.Range

This example adds a frame around the third paragraph in the selection.

Set myFrame = Selection.Frames _
    .Add(Range:=Selection.Paragraphs(3).Range)

As it applies to the HangulAndAlphabetExceptions object.

This example adds test to the list of hangul and alphabet AutoCorrect exceptions on the Korean tab in the AutoCorrect Exceptions dialog box.

AutoCorrect.HangulAndAlphabetExceptions.Add Name:="test"

As it applies to the HeadingStyles object.

This example adds a table of contents at the beginning of the active document and then adds the Title style to the list of styles used to build a table of contents.

Set myToc = ActiveDocument.TablesOfContents _
    .Add(Range:=ActiveDocument.Range(0, 0), _
    UseHeadingStyles:=True, UpperHeadingLevel:=1, _
    LowerHeadingLevel:=3)
myToc.HeadingStyles.Add Style:="Title", Level:=2

This example turns the selection into a hyperlink to the Microsoft address on the World Wide Web.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
    Address:="http:\\www.microsoft.com"

This example turns the selection into a hyperlink that links to the bookmark named MyBookMark in MyFile.doc.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
    Address:="C:\My Documents\MyFile.doc", SubAddress:="MyBookMark"

This example turns the first shape in the selection into a hyperlink.

ActiveDocument.Hyperlinks.Add Anchor:=Selection.ShapeRange(1), _
    Address:="http:\\www.microsoft.com"

As it applies to the Indexes object.

This example marks an index entry, and then it creates an index at the end of the active document.

ActiveDocument.Indexes.MarkEntry _
    Range:=Selection.Range, Entry:="My Entry"
Set MyRange = ActiveDocument.Content
MyRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Indexes.Add Range:=MyRange, Type:=wdIndexRunin

As it applies to the KeyBindings object.

This example adds the CTRL+ALT+W key combination to the FileClose command. The keyboard customization is saved in the Normal template.

CustomizationContext = NormalTemplate
KeyBindings.Add _
    KeyCategory:=wdKeyCategoryCommand, _
    Command:="FileClose", _
    KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyW)

This example adds the ALT+F4 key combination to the Arial font and then displays the number of items in the KeyBindings collection. The example then clears the ALT+F4 key combination (returned it to its default setting) and redisplays the number of items in the KeyBindings collection.

CustomizationContext = ActiveDocument.AttachedTemplate
Set myKey = KeyBindings.Add(KeyCategory:=wdKeyCategoryFont, _
    Command:="Arial", KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyF4))
MsgBox KeyBindings.Count & " keys in KeyBindings collection"
myKey.Clear
MsgBox KeyBindings.Count & " keys in KeyBindings collection"

This example adds the CTRL+ALT+S key combination to the Font command with 8 points specified for the font size.

CustomizationContext = NormalTemplate
KeyBindings.Add KeyCategory:=wdKeyCategoryCommand, _
    Command:="FontSize", _
    KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyS), _
    CommandParameter:="8"

This example adds the CTRL+ALT+H key combination to the Heading 1 style in the active document.

CustomizationContext = ActiveDocument
KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, _
    Command:="Heading 1", _
    KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyH)

This example adds the CTRL+ALT+O key combination to the AutoText entry named "Hello."

CustomizationContext = ActiveDocument
KeyBindings.Add KeyCategory:=wdKeyCategoryAutoText, _
    Command:="Hello", _
    KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyO)

As it applies to the ListEntries object.

This example inserts a drop-down form field in the active document and then adds the items Red, Blue, and Green to the form field.

Set myField = ActiveDocument.FormFields.Add(Range:= _
    Selection.Range, Type:= wdFieldFormDropDown)
With myField.DropDown.ListEntries
    .Add Name:="Red"
    .Add Name:="Blue"
    .Add Name:="Green"
End With

As it applies to the ListTemplates object.

This example adds a new, single-level list template to the active document. The example changes the numbering style for the new list template and then applies the list template to the selection.

Set myList = _
    ActiveDocument.ListTemplates.Add(OutlineNumbered:=False)
myList.ListLevels(1).NumberStyle = wdListNumberStyleUpperCaseLetter
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=myList

As it applies to the MailMergeFields object.

This example replaces the selection with a mail merge field named MiddleInitial.

ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, _
    Name:="MiddleInitial"

As it applies to the PageNumbers object.

This example adds a page number to the primary footer in the first section of the active document.

With ActiveDocument.Sections(1)
    .Footers(wdHeaderFooterPrimary).PageNumbers.Add _
        PageNumberAlignment:=wdAlignPageNumberLeft, _
        FirstPage:=True
End With

This example creates and formats page numbers in the header for the active document.

Set myPgNum = ActiveDocument.Sections(1) _
    .Headers(wdHeaderFooterPrimary) _
    .PageNumbers.Add(PageNumberAlignment:= _
    wdAlignPageNumberCenter, FirstPage:= True)
myPgNum.Select
With Selection.Range
    .Italic = True
    .Bold = True
End With

As it applies to the Panes object.

The following example splits the active window such that the top pane is 30 percent of the total window size.

ActiveDocument.ActiveWindow.Panes.Add SplitVertical:=30

As it applies to the Paragraphs object.

This example adds a paragraph after the selection.

Selection.Paragraphs.Add

This example adds a paragraph mark before the first paragraph in the selection.

Selection.Paragraphs.Add Range:=Selection.Paragraphs(1).Range

This example adds a paragraph mark before the second paragraph in the active document.

ActiveDocument.Paragraphs.Add _
    Range:=ActiveDocument.Paragraphs(2).Range

This example adds a new paragraph mark at the end of the active document.

ActiveDocument.Paragraphs.Add

As it applies to the RecentFiles object.

This example adds the active document to the list of recently used files.

If ActiveDocument.Saved = True Then
    RecentFiles.Add Document:=ActiveDocument.Name
End If

As it applies to the Rows object.

This example inserts a new row before the first row in the selection.

Sub AddARow()
    If Selection.Information(wdWithInTable) = True Then
        Selection.Rows.Add BeforeRow:=Selection.Rows(1)
    End If
End Sub

This example adds a row to the first table and then inserts the text Cell into this row.

Sub CountCells()
    Dim tblNew As Table
    Dim rowNew As Row
    Dim celTable As Cell
    Dim intCount As Integer

    intCount = 1
    Set tblNew = ActiveDocument.Tables(1)
    Set rowNew = tblNew.Rows.Add(BeforeRow:=tblNew.Rows(1))
    For Each celTable In rowNew.Cells
        celTable.Range.InsertAfter Text:="Cell " & intCount
        intCount = intCount + 1
    Next celTable
End Sub

As it applies to the Sections object.

This example adds a Next Page section break before the third paragraph in the active document.

Set myRange = ActiveDocument.Paragraphs(3).Range
ActiveDocument.Sections.Add Range:=myRange

This example adds a Continuous section break at the selection.

Set myRange = Selection.Range
ActiveDocument.Sections.Add Range:=myRange, _
    Start:=wdSectionContinuous

This example adds a Next Page section break at the end of the active document.

ActiveDocument.Sections.Add

As it applies to the Styles object.

This example adds a new character style named Introduction and makes it 12-point Arial, with bold and italic formatting. The example then applies the new character style to the selection.

Set myStyle = ActiveDocument.Styles.Add(Name:="Introduction", _
    Type:=wdStyleTypeCharacter)
With myStyle.Font
    .Bold = True
    .Italic = True
    .Name = "Arial"
    .Size = 12
End With
Selection.Range.Style = "Introduction"

As it applies to the Stylesheets object.

This example adds a style sheet to the active document and places it highest in the list of style sheets attached to the document. This example assumes that you have a style sheet document named Website.css located on your C: drive.

Sub NewStylesheet()
    ActiveDocument.StyleSheets.Add _
        FileName:="c:\WebSite.css", _
        Precedence:=wdStyleSheetPrecedenceHighest, _
        LinkType:=wdStyleSheetLinkTypeLinked, _
        Title:="Test Stylesheet"
End Sub

As it applies to the Tables object.

This example adds a blank table with three rows and four columns at the beginning of the active document.

Set myRange = ActiveDocument.Range(0, 0)
ActiveDocument.Tables.Add Range:=myRange, NumRows:=3, NumColumns:=4

This example adds a new, blank table with six rows and ten columns at the end of the active document

Set MyRange = ActiveDocument.Content
MyRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Tables.Add Range:=MyRange, NumRows:=6, _
    NumColumns:=10

This example adds a table with three rows and five columns to a new document and then inserts data into each cell in the table.

Sub NewTable()
    Dim docNew As Document
    Dim tblNew As Table
    Dim intX As Integer
    Dim intY As Integer

    Set docNew = Documents.Add
    Set tblNew = docNew.Tables.Add(Selection.Range, 3, 5)
    With tblNew
    For intX = 1 To 3
        For intY = 1 To 5
            .Cell(intX, intY).Range.InsertAfter "Cell: R" & intX & ", C" & intY
        Next intY
    Next intX
    .Columns.AutoFit
    End With
End Sub

As it applies to the TablesOfAuthorities object.

This example adds, at the beginning of the active document, a table of authorities that includes all categories.

Set myRange = ActiveDocument.Range(0, 0)
ActiveDocument.TablesOfAuthorities.Add Range:=myRange, _
    Passim:= True, Category:= 0, EntrySeparator:= ", "

As it applies to the TablesOfContents object.

This example adds a table of contents at the beginning of the active document. The table of contents is built from paragraphs styled with the Heading 1, Heading 2, and Heading 3 styles or the custom styles myStyle and yourStyle.

Set myRange = ActiveDocument.Range(0, 0)
ActiveDocument.TablesOfContents.Add _
    Range:=myRange, _
    UseFields:=False, _
    UseHeadingStyles:=True, _
    LowerHeadingLevel:=3, _
    UpperHeadingLevel:=1, _
    AddedStyles:="myStyle, yourStyle"

As it applies to the TablesOfFigures object.

This example inserts a table of figures in the active document.

ActiveDocument.TablesOfFigures.Add Range:=Selection.Range

As it applies to the TabStops object.

This example adds a tab stop positioned at 2.5 inches (from the left edge of the page) to the selected paragraphs.

Selection.Paragraphs.TabStops.Add Position:=InchesToPoints(2.5)

This example adds two tab stops to the selected paragraphs. The first tab stop is a left aligned, has a dotted leader, and is positioned at 1 inch (72 points) from the left edge of the page. The second tab stop is centered and is positioned at 2 inches from the left edge.

With Selection.Paragraphs.TabStops
    .Add Position:=InchesToPoints(1), _
        Leader:=wdTabLeaderDots, _
        Alignment:=wdAlignTabLeft
    .Add Position:=InchesToPoints(2), _
        Alignment:=wdAlignTabCenter
End With

As it applies to the TextColumns object.

This example creates a new document and then adds another 2.5-inch-wide text column to it.

Set myDoc = Documents.Add
myDoc.PageSetup.TextColumns.Add Width:=InchesToPoints(2.5), _
    Spacing:=InchesToPoints(0.5), EvenlySpaced:=False

This example adds a new text column to the active document and then evenly spaces all the text columns in the document.

ActiveDocument.PageSetup.TextColumns.Add _
    Width:=InchesToPoints(1.5), _
    EvenlySpaced:=True

As it applies to the Variables object.

This example adds a variable named Temp to the active document and then inserts a DOCVARIABLE field to display the value in the Temp variable.

With ActiveDocument
    .Variables.Add Name:="Temp", Value:="12"
    .Fields.Add Range:=Selection.Range, _
        Type:=wdFieldDocVariable, Text:="Temp"
End With
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False

This example sets the value of the Blue variable to six. If this variable doesn't already exist, the example adds it to the document and sets it to six.

For Each aVar In ActiveDocument.Variables
    If aVar.Name = "Blue" Then num = aVar.Index
Next aVar
If num = 0 Then
    ActiveDocument.Variables.Add Name:="Blue", Value:=6
Else
    ActiveDocument.Variables(num).Value = 6
End If

This example stores the user name (from the Options dialog box) in the template attached to the active document.

ScreenUpdating = False
With ActiveDocument.AttachedTemplate.OpenAsDocument
    .Variables.Add Name:="UserName", Value:= Application.UserName
    .Close SaveChanges:=wdSaveChanges
End With

As it applies to the Windows object.

This example opens a new window for the document that's displayed in the active window.

Windows.Add

This example opens a new window for MyDoc.doc.

Windows.Add Window:=Documents("MyDoc.doc").Windows(1)

As it applies to the XMLNamespaces object.

The following example adds the specified schema to the Schema Library and then attaches it to the active document. This example assumes that you have a schema named simplesample.xsd at the specified path.

Sub AddSchema()
    Dim objSchema As XMLNamespace
    
    Set objSchema = Application.XMLNamespaces _
        .Add ("c:\schemas\simplesample.xsd")
        
    objSchema.AttachToDocument ActiveDocument
End Sub

As it applies to the XMLNodes object.

The following example adds to the selected text the example element from the first schema referenced in the active document.

Sub AddNode()
    ActiveDocument.XMLNodes.Add "example", _
        ActiveDocument.XMLSchemaReferences(1).NamespaceURI, _
        Selection.Range
End Sub

As it applies to the XMLSchemaReferences object.

The following example attaches the specified schema to the active document. This example assumes that you have an xsd file located at the path specified in the Path parameter.

Sub AddSchema()
    Dim objSchema As XMLNamespace
    
    Set objSchema = Application.XMLNamespaces _
        .Add("c:\schemas\simplesample.xsd")
        
    objSchema.AttachToDocument ActiveDocument
End Sub

As it applies to the XSLTransforms object.

The following code adds a schema to the Schema Library and then adds an XSLT to the newly added schema.

Sub AddXSLT()
    Dim objSchema As XMLNamespace
    Dim objTransform As XSLTransform
    
    Set objSchema = Application.XMLNamespaces("SimpleSample")
    Set objTransform = objSchema.XSLTransforms _
        .Add("c:\schemas\simplesample.xsl")

End Sub

Applies to | AddIns Collection Object | AutoCorrectEntries Collection Object | AutoTextEntries Collection Object | Bookmarks Collection Object | CaptionLabels Collection Object | Cells Collection Object | Columns Collection Object | Comments Collection Object | CustomLabels Collection Object | CustomProperties Collection | Dictionaries Collection Object | Documents Collection Object | Editors Collection | EmailSignatureEntries Collection | Endnotes Collection Object | Fields Collection Object | FirstLetterExceptions Collection Object | Footnotes Collection Object | FormFields Collection Object | Frames Collection Object | HangulAndAlphabetExceptions Collection Object | HangulHanjaConversionDictionaries Collection Object | HeadingStyles Collection Object | HTMLDivisions Collection | Hyperlinks Collection Object | Indexes Collection Object | KeyBindings Collection Object | ListEntries Collection Object | ListTemplates Collection Object | MailMergeFields Collection Object | OtherCorrectionsExceptions Collection Object | PageNumbers Collection Object | Panes Collection Object | Paragraphs Collection Object | RecentFiles Collection Object | Rows Collection Object | Sections Collection Object | SmartTags Collection | Styles Collection Object | StyleSheets Collection | Tables Collection Object | TablesOfAuthorities Collection Object | TablesOfContents Collection Object | TablesOfFigures Collection Object | TabStops Collection Object | TextColumns Collection Object | TwoInitialCapsExceptions Collection Object | Variables Collection Object | Windows Collection Object | XMLNamespaces Collection | XMLNodes Collection | XMLSchemaReferences Collection | XSLTransforms Collection

See Also | AddAsk Method | AddFillIn Method | AddIf Method | AddMergeRec Method | AddMergeSeq Method | AddNext Method | AddNextIf Method | AddRichText Method | AddSet Method | AddShape Method | AppendToSpike Method | Apply Method | AttachedTemplate Property | AutoCaptions Property | AutoCorrect Property | AutoFormatAsYouTypeReplaceHyperlinks Property | AutoFormatReplaceHyperlinks Property | AutoMarkEntries Method | CheckBox Property | Clear Method | Comment Object | CreateNewDocument Method | CustomDictionaries Property | CustomizationContext Property | DefaultTabStop Property | DifferentFirstPageHeaderFooter Property | Disable Method | DisplayRecentFiles Property | DropDown Property | Endnotes Property | Exists Method | Fields Property | FirstLetterAutoAdd Property | FirstLetterExceptions Property | FollowHyperlink Method | Footnotes Property | FormField Object | Frame Property | HangulAndAlphabetAutoAdd Property | HangulAndAlphabetException Object | HangulHanjaDictionaries Property | HeaderFooter Object | HeadingStyles Property | Hyperlinks Property | Indexes Collection Object | InsertBreak Method | InsertCells Method | InsertParagraph Method | InsertParagraphAfter Method | InsertParagraphBefore Method | Installed Property | LinkToPrevious Property | ListEntries Collection Object | ListTemplate Object | MarkAllEntries Method | MarkCitation Method | MarkEntry Method | NewWindow Method | RecentFiles Property | SeekView Property | SetCount Method | ShowBookmarks Property | Spacing Property | Split Method | SplitSpecial Property | SplitVertical Property | TableOfContents Object | TableOfFigures Object | TablesOfAuthorities Collection Object | TablesOfContents Collection Object | TablesOfFigures Collection Object | TabStops Collection Object | TabStops Property | Templates Property | TextFrame Property | TextInput Property | TwoInitialCapsAutoAdd Property | TwoInitialCapsExceptions Property | Variables Collection Object | Windows Collection Object