Etudes for Microsoft Word Programmers. Appendix.


Information on this page is from Microsoft MSDN http://msdn.microsoft.com.

Object Selection (Word 2003)

Represents the current selection in a window or pane. A selection represents either a selected (or highlighted) area in the document, or it represents the insertion point if nothing in the document is selected. There can only be one Selection object per document window pane, and only one Selection object in the entire application can be active.

Selection Object Properties

Selection object properties are listed in the following table.

Active

Read-only Boolean.

True if the selection in the specified window or pane is active.

Application

 

Used without an object qualifier, this property returns an Application object that represents the Microsoft Word application. Used with an object qualifier, this property returns an Application object that represents the creator of the specified object. When used with an OLE Automation object, it returns the object's application.
Remarks
Visual Basic's CreateObject and GetObject functions give you access to an OLE Automation object from a Visual Basic for Applications project.

BookmarkID

Read-only Long

Returns the number of the bookmark that encloses the beginning of the specified selection or range; returns 0 (zero) if there's no corresponding bookmark. The number corresponds to the position of the bookmark in the document 1 for the first bookmark, 2 for the second one, and so on.

Bookmarks

Read-only

Returns a Bookmarks collection that represents all the bookmarks in a document, range, or selection.

Borders

 

Returns a Borders collection that represents all the borders for the specified object.

Cells

Read-only

Returns a Cells collection that represents the table cells in a column, row, selection, or range.

Characters

Read-only

Returns a Characters collection that represents the characters in a document, range, or selection.

ChildShapeRange

 

Returns a ShapeRange object representing the child shapes of a selection.

Columns

Read-only

Returns a Columns collection that represents all the table columns in the range, selection, or table.

ColumnSelectMode

Read/write Boolean

True if column selection mode is active. When this mode is active, the letters "COL" appear on the status bar.

Comments

Read-only

Returns a Comments collection that represents all the comments in the specified document, selection, or range.

Creator

Read-only Long

 

Document

Read-only

Returns a Document object associated with the specified pane, window, or selection.

Editors

 

Returns an Editors object that represents all the users authorized to modify a selection or range within a document.

End

Read/write Long

Returns or sets the ending character position of a selection, range, or bookmark.
Note  If this property is set to a value smaller than the Start property, the Start property is set to the same value (that is, the Start and End property are equal).
Remarks
The Selection, Range, and Bookmark objects all have a starting position and an ending position. The ending position is the point farthest away from the beginning of the story.
This property returns the ending character position relative to the beginning of the story. The main document story (wdMainTextStory) begins with character position 0 (zero). You can change the size of a selection, range, or bookmark by setting this property.

EndnoteOptions

 

Returns an EndnoteOptions object that represents the endnotes in a range or selection.

Endnotes

Read-only

Returns an Endnotes collection that represents all the endnotes in a range, selection, or document.

EnhMetaFileBits

 

Returns a Variant that represents a picture representation of how a selection or range of text appears.
Note  The EnhMetaFileBits property returns an array of bytes, which can be used with the Microsoft Windows 32 Application Programming Interface from within the Microsoft Visual Basic or Microsoft C++ development environment.

ExtendMode

Read/write Boolean

True if Extend mode is active. When Extend mode is active, the Extend argument of the following methods is True by default: EndKey , HomeKey , MoveDown , MoveLeft , MoveRight , and MoveUp . Also, the letters "EXT" appear on the status bar.
Remarks
This property can only be set during run time; attempts to set it in Immediate mode are ignored. The Extend arguments of the EndOf and StartOf methods are not affected by this property.

Fields

 

Returns a read-only Fields collection that represents all the fields in the document, range, or selection.

Find

Read-only

Returns a Find object that contains the criteria for a find operation.
Note  When this property is used with a Selection object, the selection is changed if the find operation is successful. If this property is used with a Range object, the selection isn't changed unless the Select method is applied.

FitTextWidth

Read/write Single

Returns or sets the width (in the current measurement units) in which Microsoft Word fits the text in the current selection or range.

Flags

 Read/write WdSelectionFlags

Returns or sets properties of the selection.
The return value of the Flags property is the sum of the WdSelectionFlags constants that apply to the selection.
Note  Setting the Flags property to wdSelAtEOL wil make the end of the selection active.

Font

Read/write Font

Returns or sets a Font object that represents the character formatting of the specified object. To set this property, specify an expression that returns a Font object.

FootnoteOptions

 FootnoteOptions object

Returns FootnoteOptions object that represents the footnotes in a selection or range.

Footnotes

Read-only

Returns a Footnotes collection that represents all the footnotes in a range, selection, or document.

FormattedText

Read/write

Returns or sets a Range object that includes the formatted text in the specified range or selection.
Remarks
This property returns a Range object with the character formatting and text from the specified range or selection. Paragraph formatting is included in the Range object if there's a paragraph mark in the range or selection.
When you set this property, the text in the range is replaced with formatted text. If you don't want to replace the existing text, use the Collapse method before using this property (see the first example).

FormFields

Read-only

Returns a FormFields collection that represents all the form fields in the document, range, or selection.

Frames

Read-only

Returns a Frames collection that represents all the frames in a document, range, or selection.

HasChildShapeRange

Read-only Boolean

True if the selection contains child shapes.

HeaderFooter

Read-only

Returns a HeaderFooter object for the specified selection or range.
Note  An error occurs if the selection isn't located within a header or footer.

HTMLDivisions

 HTMLDivisions object

Returns an HTMLDivisions object that represents an HTML division in a Web document.

Hyperlinks

Read-only

Returns a Hyperlinks collection that represents all the hyperlinks in the specified document, range, or selection.

Information(Type)

Read-only Variant

Returns information about the specified selection or range.

Type   Required WdInformation . The information type.

InlineShapes

Read-only

Returns an InlineShapes collection that represents all the InlineShape objects in a document, range, or selection.

IPAtEndOfLine

Read-only Boolean

True if the insertion point is at the end of a line that wraps to the next line. False if the selection isn't collapsed, if the insertion point isn't at the end of a line, or if the insertion point is positioned before a paragraph mark.

IsEndOfRowMark

Read-only Boolean

True if the specified selection or range is collapsed and is located at the end-of-row mark in a table.

LanguageDetected

Read/write Boolean

Returns or sets a value that specifies whether Microsoft Word has detected the language of the specified text.
Remarks
Check the LanguageID property for the results of any previous language detection.
The LanguageDetected property is set to True when the DetectLanguage method is called. To reevaluate the language of the specified text, you must first set the LanguageDetected property to False.
For more information about automatic language detection, see About automatic language detection .

LanguageID

Read/write WdLanguageID

Returns or sets the language for the specified object.
Remarks
For a custom dictionary, you must first set the LanguageSpecific property to True before specifying the the LanguageID property. Custom dictionaries that are language specific only look at text formatted for that language.
Some of the constants listed above may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

LanguageIDFarEast

Read/write WdLanguageID

Returns or sets an East Asian language for the specified object.
Remarks
This is the recommended way to return or set the language of East Asian text in a document created in an East Asian version of Microsoft Word.

LanguageIDOther

Read/write WdLanguageID

Returns or sets the language for the specified object. 
Remarks
This is the recommended way to return or set the language of Latin text in a document created in a right-to-left language version of Microsoft Word.

NoProofing

Read/write Long

True if the spelling and grammar checker ignores the specified text. Returns wdUndefined if the NoProofing property is set to True for only some of the specified text.
Example
This example searches for the string "hi" in text that the spelling and grammar checker ignores.

Orientation

Read/write WdTextOrientation

Returns or sets the orientation of text in a range or selection when the Text Direction feature is enabled. 
Remarks
Some of the constants listed above may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.
You can set the orientation for a text frame or for a range or selection that happens to occur inside a text frame. For information about the difference between a text frame and a text box, see the TextFrame object.

PageSetup

Read-only

Returns a PageSetup object that's associated with the specified document, range, section, sections, or selection.

ParagraphFormat

Read/write

Returns or sets a ParagraphFormat object that represents the paragraph settings for the specified range, selection, find or replacement operation, or style.

Paragraphs

Read-only

Returns a Paragraphs collection that represents all the paragraphs in the specified document, range, or selection.

Parent

 

 

PreviousBookmarkID

Read-only Long

Returns the number of the last bookmark that starts before or at the same place as the specified selection or range; returns 0 (zero) if there's no corresponding bookmark.

Range

 

Returns a Range object that represents the portion of a document that's contained in the specified object.

Rows

Read-only

Returns a Rows collection that represents all the table rows in a range, selection, or table.

Sections

Read-only

Returns a Sections collection that represents the sections in the specified document, range, or selection.

Sentences

Read-only

Returns a Sentences collection that represents all the sentences in the range, selection, or document.

Shading

 

Returns a Shading object that refers to the shading formatting for the specified object.

ShapeRange

Read-only

Returns a ShapeRange collection that represents all the Shape objects in the specified range or selection. The shape range can contain drawings, shapes, pictures, OLE objects, ActiveX controls, text objects, and callouts.

SmartTags

 

Returns a SmartTags object that represents a smart tag in a document.

Start

Read/write Long

Returns or sets the starting character position of a selection, range, or bookmark.
Note  If this property is set to a value larger than that of the End property, the End property is set to the same value as that of Start property.
Remarks
Selection, Range, and Bookmark objects have starting and ending character positions. The starting position refers to the character position closest to the beginning of the story.
This property returns the starting character position relative to the beginning of the story. The main text story (wdMainTextStory) begins with character position 0 (zero). You can change the size of a selection, range, or bookmark by setting this property.

StartIsActive

Read/write Boolean

True if the beginning of the selection is active. If the selection is not collapsed to an insertion point, either the beginning or the end of the selection is active. The active end of the selection moves when you call the following methods: EndKey , Extend (with the Characters argument), HomeKey , MoveDown , MoveLeft , MoveRight , and MoveUp.
Remarks
This property is equivalent to using the Flags property with the wdSelStartActive constant. However, using the Flags property requires binary operations, which are more complicated than using the StartIsActive property.

StoryLength

Read-only Long

Returns the number of characters in the story that contains the specified range or selection.

StoryType

Read-only WdStoryType

Returns the story type for the specified range, selection, or bookmark.

Style

Read/write Variant

Returns or sets the style for the specified object. To set this property, specify the local name of the style, an integer, a WdBuiltinStyle constant, or an object that represents the style. For a list of valid constants, consult the Microsoft Visual Basic Object Browser.
Remarks
When you return the style for a range that includes more than one style, only the first character or paragraph style is returned.

Tables

Read-only

Returns a Tables collection that represents all the tables in the specified cell, document, range, selection, or table.

Text

Read/write String

Returns or sets the text in the specified range or selection. 
Remarks
The Text property returns the plain, unformatted text of the selection or range. When you set this property, the text of the range or selection is replaced.

TopLevelTables

 Read-only Tables collection

Returns a Tables collection that represents the tables at the outermost nesting level in the current range or selection.
Remarks
This method returns a collection containing only those tables at the outermost nesting level within the context of the current range or selection. These tables may not be at the outermost nesting level within the entire set of nested tables.

Type

Read-only WdSelectionType

Returns the selection type.

Words

Read-only

Returns a Words collection that represents all the words in a range, selection, or document.
Note  Punctuation and paragraph marks in a document are included in the Words collection.

XML(DataOnly)

 String

Returns a String that represents the XML text in the specified object.
DataOnly   Optional Boolean. True returns the text of the XML without the Word XML markup. The default setting is False.

XMLNodes

XMLNodes collection

Returns an XMLNodes collection that represents the collection of all XML elements within a document or in a selection or rangeincluding those elements that are only partially within the selection or range.

XMLParentNode

 XMLNode object

Returns an XMLNode object that represents the parent node of a selection or range.

 Selection Object Methods

Selection object methods are listed in the following table.

BoldRun

Adds the bold character format to or removes it from the current run. If the run contains a mix of bold and non-bold text, this method adds the bold character format to the entire run.
Remarks
For more information on using Microsoft Word with right-to-left languages, see Word features for right-to-left languages .

Calculate

Calculates a mathematical expression within a range or selection. Returns the result as a Single.

ClearFormatting

Removes text and paragraph formatting from a selection or from the formatting specified in a find or replace operation.
Remarks
To ensure that formatting isn't included as criteria in a find or replace operation, use this method before carrying out the operation.

Collapse(Direction)

Collapses a range or selection to the starting or ending position. After a range or selection is collapsed, the starting and ending points are equal.
Direction    Optional Variant. The direction in which to collapse the range or selection. Can be either of the following WdCollapseDirection constants: wdCollapseEnd or wdCollapseStart. The default value is wdCollapseStart.
Remarks
If you use wdCollapseEnd to collapse a range that refers to an entire paragraph, the range is located after the ending paragraph mark (the beginning of the next paragraph). However, you can move the range back one character by using the MoveEnd method after the range is collapsed, as shown in the following example.

ConvertToTable(Separator,
NumRows,
NumColumns, InitialColumnWidth, Format,
ApplyBorders, ApplyShading,
ApplyFont,
ApplyColor, ApplyHeadingRows, ApplyLastRow, ApplyFirstColumn, ApplyLastColumn,
AutoFit,
AutoFitBehavior, DefaultTableBehavior
)

Converts text within a range or selection to a table. Returns the table as a Table object.
Separator    Optional Variant. Specifies the character used to separate text into cells. Can be a character or one of the following WdTableFieldSeparator constant. If this argument is omitted, the value of the DefaultTableSeparator property is used.
NumRows    Optional Variant. The number of rows in the table. If this argument is omitted, Microsoft Word sets the number of rows, based on the contents of the range or selection.
NumColumns    Optional Variant. The number of columns in the table. If this argument is omitted, Word sets the number of columns, based on the contents of the range or selection.
InitialColumnWidth    Optional Variant. The initial width of each column, in points. If this argument is omitted, Word calculates and adjusts the column width so that the table stretches from margin to margin.
Format    Optional Variant. Specifies one of the predefined formats listed in the Table AutoFormat dialog box (Table menu). Can be one of the WdTableFormat constants.
ApplyBorders    Optional Variant. True to apply the border properties of the specified format.
ApplyShading    Optional Variant. True to apply the shading properties of the specified format.
ApplyFont    Optional Variant. True to apply the font properties of the specified format.
ApplyColor    Optional Variant. True to apply the color properties of the specified format.
ApplyHeadingRows    Optional Variant. True to apply the heading-row properties of the specified format.
ApplyLastRow    Optional Variant. True to apply the last-row properties of the specified format.
ApplyFirstColumn    Optional Variant. True to apply the first-column properties of the specified format.
ApplyLastColumn    Optional Variant. True to apply the last-column properties of the specified format.
AutoFit    Optional Variant. True to decrease the width of the table columns as much as possible without changing the way text wraps in the cells.
AutoFitBehavior    Optional Variant. Sets the AutoFit rules for how Word sizes a table. Can be one of the following WdAutoFitBehavior constant. If DefaultTableBehavior is wdWord8TableBehavior, this argument is ignored.
DefaultTableBehavior    Optional Variant. Sets a value that specifies whether Microsoft Word automatically resizes cells in a table to fit the contents (AutoFit). Can be one of the following WdDefaultTableBehavior constant.

Copy

Copies the specified object to the Clipboard.

CopyAsPicture

The CopyAsPicture method works the same way as the Copy method for Range and Selection objects.

CopyFormat

Copies the character formatting of the first character in the selected text. If a paragraph mark is selected, Word copies paragraph formatting in addition to character formatting.
Note  You can apply the copied formatting to another selection by using the PasteFormat method.

CreateAutoTextEntry(
Name,
StyleName
)

Adds a new AutoTextEntry object to the AutoTextEntries collection, based on the current selection.
Name    Required String. The text the user must type to call the new AutoText entry.
StyleName    Required String. The category in which the new AutoText entry will be listed on the AutoText menu.

CreateTextbox

Adds a default-size text box around the selection. If the selection is an insertion point, this method changes the pointer to a cross-hair pointer so that the user can draw a text box.
Remarks
Using this method is equivalent to clicking the Text Box button on the Drawing toolbar. A text box is a rectangle with an associated text frame.

Cut

Removes the specified object from the document and places it on the Clipboard.
Remarks
If expression returns a Range or Selection object, the contents of the object are cut to the Clipboard but the collapsed object remains in the document.

Delete(Unit, Count)

Deletes the specified number of characters or words. This method returns a Long value that indicates the number of items deleted, or it returns 0 (zero) if the deletion was unsuccessful.
Unit   Optional Variant. The unit by which the collapsed range or selection is to be deleted. Can be one of the following WdUnits constants: wdCharacter (default) or wdWord.
Count   Optional Variant. The number of units to be deleted. To delete units after the range or selection, collapse the range or selection and use a positive number. To delete units before the range or selection, collapse the range or selection and use a negative number.

DetectLanguage

Analyzes the specified text to determine the language that it is written in.
Remarks
The results of the DetectLanguage method are stored in the LanguageID property on a character-by-character basis. To read the LanguageID property, you must first specify a selection or range of text.
When applied to a Document object, the DetectLanguage method checks all available text in the document (headers, footers, text boxes, and so forth). If the specified text contains a partial sentence, the selection or range is extended to the end of the sentence.
If the DetectLanguage method has already been applied to the specified text, the LanguageDetected property is set to True. To reevaulate the language of the specified text, you must first set the LanguageDetected property to False.

EndKey(Unit, Extend)

Moves or extends the selection to the end of the specified unit. This method returns an integer that indicates the number of characters the selection or active end was actually moved, or it returns 0 (zero) if the move was unsuccessful.
Note  This method corresponds to functionality of the END key.
Unit    Optional Variant. The unit by which the selection is to be moved or extended. WdUnits. Can be one of the following WdUnits constants: wdStory, wdColumn, wdLine or wdRow. The default value is wdLine.
Extend    Optional Variant. Specifies the way the selection is moved. WdMovementType . Can be one of the following WdMovementType constants: wdMove or wdExtend.
If the value of this argument is wdMove, the selection is collapsed to an insertion point and moved to the end of the specified unit. If it's wdExtend, the end of the selection is extended to the end of the specified unit. The default value is wdMove.

EndOf(Unit, Extend)

Moves or extends the ending character position of a range or selection to the end of the nearest specified text unit. This method returns a value that indicates the number of character positions the range or selection was moved or extended (movement is forward in the document).
Unit    Optional Variant. The unit by which to move the ending character position. WdUnits. Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow or wdTable.

If expression returns a Selection object, wdLine can also be used. The default value is wdWord.
Extend    Optional Variant.WdMovementType . Can be either of the following WdMovementType constants: wdMove or wdExtend.
If wdMove, both ends of the range or selection object are moved to the end of the specified unit. If wdExtend is used, the end of the range or selection is extended to the end of the specified unit. The default value is wdMove.

Remarks
If the both the starting and ending positions for the range or selection are already at the end of the specified unit, this method doesn't move or extend the range or selection. For example, if the selection is at the end of a word and the trailing space, the following instruction doesn't change the selection (char equals 0 (zero)).

EscapeKey

Cancels a mode such as extend or column select (equivalent to pressing the ESC key).

Expand(Unit)

Expands the specified range or selection. Returns the number of characters added to the range or selection. Long.
Unit    Optional Variant. The unit by which to expand the range. WdUnits .
Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow or wdTable. If expression represents a Selection object, wdLine can also be used. The default value is wdWord.

Extend(Character)

Turns extend mode on (sets the ExtendMode property to True), or if extend mode is already on, extends the selection to the next larger unit of text. The progression of selected units of text is as follows: word, sentence, paragraph, section, entire document.
If Character is specified, extends the selection forward through the next instance of the specified character. The selection is extended by moving the active end of the selection.
Character   Optional Variant. The character through which the selection is extended. This argument is case sensitive and must evaluate to a String or an error occurs. Also, if the value of this argument is longer than a single character, Microsoft Word ignores the command entirely.

GoTo(
What,
Which,
Count,
Name
)

Moves the insertion point to the character position immediately preceding the specified item, and returns a Range object (except for the wdGoToGrammaticalError, wdGoToProofreadingError, or wdGoToSpellingError constant).
What   Optional Variant. The kind of item to which the range or selection is moved. Can be one of the WdGoToItem constants.
Which   Optional Variant. The item to which the range or selection is moved. Can be one of the WdGoToDirection constants. The following examples are functionally equivalent; they both move the selection to the first heading in the document.
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=1

Count   Optional Variant. The number of the item in the document. The default value is 1. The following example moves the selection to the fourth line in the document.
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4

Only positive values are valid. To specify an item that precedes the range or selection, use wdGoToPrevious as the Which argument and specify a Count value. The following example moves the selection up two lines.
Selection.GoTo What:=wdGoToLine, Which:=wdGoToPrevious, Count:=2

Name   Optional Variant. If the What argument is wdGoToBookmark, wdGoToComment, wdGoToField, or wdGoToObject, this argument specifies a name. The following example moves to the next DATE field.
Selection.GoTo What:=wdGoToField, Name:="Date"

Remarks
When you use the GoTo method with the wdGoToGrammaticalError, wdGoToProofreadingError, or wdGoToSpellingError constant, the Range that's returned includes any grammar error text or spelling error text.

GoToEditableRange
(EditorID)

Returns a Range object that represents an area of a document that can be modified by the specified user or group of users.
EditorID    Optional Variant. Can be either a String that represents the user's e-mail alias (if in the same domain), an e-mail address, or a WdEditorType constant that represents a group of users. If omitted, selects all ranges for which all users have permissions to edit. 
Remarks
You can also use the NextRange property of the Editor object to return the next range for which the user has permission to modify.

GoToNext(What)

Returns a Range object that refers to the start position of the next item or location specified by the What argument. If you apply this method to the Selection object, the method moves the selection to the specified item (except for the wdGoToGrammaticalError, wdGoToProofreadingError, and wdGoToSpellingError constants). Range object.
Note   When you use this method with the wdGoToGrammaticalError, wdGoToProofreadingError, or wdGoToSpellingError constant, the Range object that's returned includes any grammar error text or spelling error text.
What   Required WdGoToItem .

GoToPrevious(What)

Returns a Range object that refers to the start position of the previous item or location specified by the What argument. If applied to a Selection object, GoToPrevious moves the selection to the specified item. Range object.
What   Required The item that the specified range or selection is to be moved to. WdGoToItem.

HomeKey(Unit, Extend)

Moves or extends the selection to the beginning of the specified unit. This method returns an integer that indicates the number of characters the selection was actually moved, or it returns 0 (zero) if the move was unsuccessful.
Note  This method corresponds to functionality of the HOME key.
Unit    Optional Variant. The unit by which the selection is to be moved or extended. WdUnits. Can be one of the following WdUnits constants. wdStory, wdColumn, wdLine or wdRow. The default value is wdLine.
Extend    Optional Variant. Specifies the way the selection is moved. WdMovementType. Can be one of the following WdMovementType constants. wdMove or wdExtend.
If the value of this argument is wdMove, the selection is collapsed to an insertion point and moved to the beginning of the specified unit. If it's wdExtend, the beginning of the selection is extended to the beginning of the specified unit. The default value is wdMove.

InRange(Range)

Returns True if the range or selection to which the method is applied is contained in the range specified by the Range argument.
Range    Required Range object. The range to which you want to compare expression.
Remarks
This method determines whether the range or selection returned by expression is contained in the specified Range by comparing the starting and ending character positions, as well as the story type.

InsertAfter(Text)

Inserts the specified text at the end of a range or selection. After this method is applied, the range or selection expands to include the new text.
Text    Required String. The text to be inserted.
Remarks
You can insert characters such as quotation marks, tab characters, and nonbreaking hyphens by using the Visual Basic Chr function with the InsertAfter method. You can also use the following Visual Basic constants: vbCr, vbLf, vbCrLf and vbTab.
If you use this method with a range or selection that refers to an entire paragraph, the text is inserted after the ending paragraph mark (the text will appear at the beginning of the next paragraph). To insert text at the end of a paragraph, determine the ending point and subtract 1 from this location (the paragraph mark is one character), as shown in the following example.

InsertBefore(Text)

Inserts the specified text before the specified selection or range. After the text is inserted, the selection or range is expanded to include the new text. If the selection or range is a bookmark, the bookmark is also expanded to include the next text.
Text    Required String. The text to be inserted.
Remarks
You can insert characters such as quotation marks, tab characters, and nonbreaking hyphens by using the Visual Basic Chr function with the InsertBefore method. You can also use the following Visual Basic constants: vbCr, vbLf, vbCrLf and vbTab.

InsertBreak(Type)

Inserts a page, column, or section break.
Type    Optional Variant. The type of break to be inserted. WdBreakType. The default value is wdPageBreak.
Remarks
When you insert a page or column break, the range or selection is replaced by the break. If you don't want to replace the range or selection, use the Collapse method before using the InsertBreak method. When you insert a section break, the break is inserted immediately preceding the Range or Selection object.
Some of the constants listed above may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

InsertCaption(
Label,
Title,
TitleAutoText,
Position,
ExcludeLabel
)

Inserts a caption immediately preceding or following the specified range or selection.
Label    Required Variant. The caption label to be inserted. WdCaptionLabelID. Can be a string or one of the following WdCaptionLabelID constants. wdCaptionEquation, wdCaptionFigure or wdCaptionTable. If the label hasn't yet been defined, an error occurs. Use the Add method with the CaptionLabels object to define new caption labels.
Title    Optional Variant. The string to be inserted immediately following the label in the caption (ignored if TitleAutoText is specified).
TitleAutoText    Optional Variant. The AutoText entry whose contents you want to insert immediately following the label in the caption (overrides any text specified by Title).
Position    Optional Variant. Specifies whether the caption will be inserted above or below the Selection or Range object. WdCaptionPosition. Can be either of the following WdCaptionPosition constants: wdCaptionPositionAbove orwdCaptionPositionBelow.
ExcludeLabel    Optional Variant. True does not include the text label, as defined in the Label parameter. False includes the specified label.

InsertCells(ShiftCells)

Adds cells to an existing table. The number of cells inserted is equal to the number of cells in the selection.
Note  You can also insert cells by using the Add method of the Cells object.
ShiftCells    Optional WdInsertCells .

InsertColumns

Inserts columns to the left of the column that contains the selection. If the selection isn't in a table, an error occurs.
Note  The number of columns inserted is equal to the number of columns selected. You can also insert columns by using the Add method of the Columns object.

InsertColumnsRight

Inserts columns to the right of the current selection.
Remarks
Microsoft Word inserts as many columns as there are in the current selection.
In order to use this method, the current selection must be in a table.

InsertCrossReference(
ReferenceType, ReferenceKind, ReferenceItem, InsertAsHyperlink, IncludePosition, SeparateNumbers, SeparatorString)

Inserts a cross-reference to a heading, bookmark, footnote, or endnote, or to an item for which a caption label is defined (for example, an equation, figure, or table).
ReferenceType   Required Variant. The type of item for which a cross-reference is to be inserted. Can be any WdReferenceType or WdCaptionLabelID constant or a user defined caption label.
ReferenceKind   Required WdReferenceKind. The information to be included in the cross-reference.
ReferenceItem   Required Variant. If ReferenceType is wdRefTypeBookmark, this argument specifies a bookmark name. For all other ReferenceType values, this argument specifies the item number or name in the Reference type box in the Cross-reference dialog box. Use the GetCrossReferenceItems method to return a list of item names that can be used with this argument.
InsertAsHyperlink   Optional Variant. True to insert the cross-reference as a hyperlink to the referenced item.
IncludePosition   Optional Variant. True to insert "above" or "below," depending on the location of the reference item in relation to the cross-reference.
SeparateNumbers Optional Variant. True to use a separator to separate the numbers from the associated text. (Use only if the ReferenceType parameter is set to wdRefTypeNumberedItem and the ReferenceKind parameter is set to wdNumberFullContext.)
SeparatorString Optional Variant. Specifies the string to use as a separator if the SeparateNumbers parameter is set to True.
Remarks
If you specify wdPageNumber for the value of ReferenceKind, you may need to repaginate the document in order to see the correct cross-reference information.

InsertDateTime(
DateTimeFormat, InsertAsField, InsertAsFullWidth, DateLanguage, CalendarType)

Inserts the current date or time, or both, either as text or as a TIME field.
DateTimeFormat    Optional Variant. The format to be used for displaying the date or time, or both. If this argument is omitted, Microsoft Word uses the short-date style from the Windows Control Panel (Regional Settings icon).
InsertAsField    Optional Variant. True to insert the specified information as a TIME field. The default value is True.
InsertAsFullWidth    Optional Variant. True to insert the specified information as double-byte digits. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.
DateLanguage    Optional Variant. Sets the language in which to display the date or time. Can be either of the following WdDateLanguage constants: wdDateLanguageBidi or wdDateLanguageLatin. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.
CalendarType    Optional Variant. Sets the calendar type to use when displaying the date or time. Can be either of the following WdCalendarTypeBi constants: wdCalendarTypeBidi or wdCalendarTypeGregorian. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

InsertFile(
FileName,
Range, ConfirmConversions,
Link,
Attachment
)

Inserts all or part of the specified file.
FileName    Required String. The path and file name of the file to be inserted. If you don't specify a path, Word assumes the file is in the current folder.
Range    Optional Variant. If the specified file is a Word document, this parameter refers to a bookmark. If the file is another type (for example, a Microsoft Excel worksheet), this parameter refers to a named range or a cell range (for example, R1C1:R3C4).
ConfirmConversions    Optional Variant. True to have Word prompt you to confirm conversion when inserting files in formats other than the Word Document format.
Link    Optional Variant. True to insert the file by using an INCLUDETEXT field.
Attachment    Optional Variant. True to insert the file as an attachment to an e-mail message.

InsertFormula(
Formula,
NumberFormat
)

Inserts an = (Formula) field that contains a formula at the selection.
Note  The formula replaces the selection, if the selection isn't collapsed.
Formula    Optional Variant. The mathematical formula you want the = (Formula) field to evaluate. Spreadsheet-type references to table cells are valid. For example, "=SUM(A4:C4)" specifies the first three values in the fourth row. For more information about the = (Formula) field, see Field codes:= (Formula) field.
NumberFormat    Optional Variant. A format for the result of the = (Formula) field. For information about the types of formats you can apply, see Numeric Picture (\#) field switch .
Remarks
If you're using a spreadsheet application, such as Microsoft Excel, embedding all or part of a worksheet in a document is often easier than using the = (Formula) field in a table.
The Formula argument is optional only if the selection is in a cell and there's at least one cell that contains a value above or to the left of the cell that contains the insertion point. If the cells above the insertion point contain values, the inserted field is {=SUM(ABOVE)}; if the cells to the left of the insertion point contain values, the inserted field is {=SUM(LEFT)}. If both the cells above the insertion point and the cells to the left of it contain values, Microsoft Word uses the following rules to determine which SUM function to insert:
If the cell immediately above the insertion point contains a value, Word inserts {=SUM(ABOVE)}.
If the cell immediately above the insertion point doesn't contain a value but the cell immediately to the left of the insertion point does, Word inserts {=SUM(LEFT)}.
If neither cell immediately above the insertion point nor the cell immediately below it contains a value, Word inserts {=SUM(ABOVE)}.
If you don't specify Formula and all the cells above and to the left of the insertion point are empty, using the = (Formula) field causes an error.

InsertParagraph

Replaces the specified range or selection with a new paragraph.
Note  After this method has been used, the range or selection is the new paragraph.
Remarks
If you don't want to replace the range or selection, use the Collapse method before using this method. The InsertParagraphAfter method inserts a new paragraph following a Range or Selection object.

InsertParagraphAfter

Inserts a paragraph mark after a range or selection.
Note  After this method is applied, the range or selection expands to include the new paragraph.

InsertParagraphBefore

Inserts a new paragraph before the specified selection or range.
Note  After this method is applied, the range or selection expands to include the new paragraph.

InsertRows(NumRows)

Inserts the specified number of new rows above the row that contains the selection. If the selection isn't in a table, an error occurs.
Note  You can also insert rows by using the Add method of the Rows object.
NumRows    Optional Variant. The number of rows to be added.

InsertRowsAbove

Inserts rows above the current selection.
Remarks
Microsoft Word inserts as many rows as there are in the current selection.
In order to use this method, the current selection must be in a table.

InsertRowsBelow

Inserts rows below the current selection.
Remarks
Microsoft Word inserts as many rows as there are in the current selection.
In order to use this method, the current selection must be in a table.

InsertStyleSeparator

Inserts a special hidden paragraph mark that allows Microsoft Word to join paragraphs formatted using different paragraph styles, so lead-in headings can be inserted into a table of contents.

InsertSymbol(
CharacterNumber,
Font,
Unicode,
Bias
)

Inserts a symbol in place of the specified range or selection.
Note  If you don't want to replace the range or selection, use the Collapse method before you use this method.
CharacterNumber    Required Long. The character number for the specified symbol. This value will always be the sum of 31 and the number that corresponds to the position of the symbol in the table of symbols (counting from left to right). For example, to specify a delta character at position 37 in the table of symbols in the Symbol font, set CharacterNumber to 68.
Font    Optional Variant. The name of the font that contains the symbol.
Unicode    Optional Variant. True to insert the unicode character specified by CharacterNumber; False to insert the ANSI character specified by CharacterNumber. The default value is False.
Bias    Optional Variant. Sets the font bias for symbols. This argument is useful for setting the correct font bias for East Asian characters. Can be one of the following WdFontBias constants: wdFontBiasDefault, wdFontBiasDontCare, or wdFontBiasFareast. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

InsertXML(
XML,
Transform
)

Inserts the specified XML text into the specified range or selection. If the specified range or selection contains text, the InsertXML method replaces the existing text.
XML    Required String. The XML text to insert.
Transform    Optional Variant. The transform to apply to the inserted XML text.
Remarks
Use the InsertXML method to insert text marked up with either arbitrary XML or Word XML. The XML must be well formed. If it uses Word XML, then it must also be valid according to the Word XML schema. For more information on the Word XML schema, please refer to the Word XML Content Development Kit, which you can find on the Microsoft Developer Network (MSDN) Web site.
If the specified XML text cannot be inserted into the specified range or selection, an error message is displayed.

InStory(Range)

True if the selection or range to which this method is applied is in the same story as the range specified by the Range argument.
Note  A range can belong to only one story.
Range    Required Range object. The Range object whose story is compared with the story that contains expression.

IsEqual(Range)

True if the selection or range to which this method is applied is equal to the range specified by the Range argument. This method compares the starting and ending character positions, as well as the story type. If all three of these items are the same for both objects, the objects are equal.
Range    Required Range object. The Range object that's compared with expression.

ItalicRun

Adds the italic character format to or removes it from the current run. If the run contains a mix of italic and non-italic text, this method adds the italic character format to the entire run.

LtrPara

Sets the reading order and alignment of the specified paragraphs to left-to-right.

expression.LtrPara

expression Required. An expression that returns a Selection object.

Remarks

For all selected paragraphs, this method sets the reading order to left-to-right. If a paragraph with a right-to-left reading order is also right-aligned, this method reverses its reading order and sets its paragraph alignment to left-aligned.

Use the ReadingOrder property to change the reading order without affecting paragraph alignment.

For more information on using Microsoft Word with right-to-left languages, see Word features for right-to-left languages .

LtrRun

Sets the reading order and alignment of the specified run to left-to-right.

expression.LtrRun

expression Required. An expression that returns a Selection object.

Remarks

For the specified run, this method sets the reading order to left-to-right. If a paragraph in the run with a right-to-left reading order is also right-aligned, this method reverses its reading order and sets its paragraph alignment to left-aligned.

Use the ReadingOrder property to change the reading order without affecting paragraph alignment.

For more information on using Microsoft Word with right-to-left languages, see Word features for right-to-left languages .

Move

Collapses the specified range or selection to its start or end position and then moves the collapsed object by the specified number of units. This method returns a Long value that indicates the number of units by which the object was actually moved, or it returns 0 (zero) if the move was unsuccessful.

expression.Move(Unit, Count)

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

Unit   Optional Variant. The unit by which the collapsed range or selection is to be moved. Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow, or wdTable. If expression returns a Selection object, you can also use wdLine. The default value is wdCharacter.

Count   Optional Variant. The number of units by which the specified range or selection is to be moved. If Count is a positive number, the object is collapsed to its end position and moved backward in the document by the specified number of units. If Count is a negative number, the object is collapsed to its start position and moved forward by the specified number of units. The default value is 1. You can also control the collapse direction by using the Collapse method before using the Move method. If the range or selection is in the middle of a unit or isn't collapsed, moving it to the beginning or end of the unit counts as moving it one full unit.

Remarks

The start and end positions of a collapsed range or selection are equal.

Applying the Move method to a range doesn't rearrange text in the document. Instead, it redefines the range to refer to a new location in the document.

If you apply the Move method to any range other than a Range object variable (for example, Selection.Paragraphs(3).Range.Move), the method has no effect.

Moving a Selection object collapses the selection and moves the insertion point either forward or backward in the document.

MoveDown

Moves the selection down and returns the number of units it's been moved.

Note  The wdWindow constant can be used to move to the top or bottom of the active window. Regardless of the value of Count (greater than 1 or less than 1), the wdWindow constant moves only one unit. Use the wdScreen constant to move more than one screen.

expression.MoveDown(Unit, Count, Extend)

expression Required. An expression that returns a Selection object.

Unit    Optional WdUnits . The unit by which the selection is to be moved.

Can be one of the following WdUnits constants.

wdLine, wdParagraph, wdWindow or wdScreen.

The default value is wdLine.

Count    Optional Variant. The number of units the selection is to be moved. The default value is 1.

Extend    Optional Variant. Can be either wdMove or wdExtend. If wdMove is used, the selection is collapsed to the end point and moved down. If wdExtend is used, the selection is extended down. The default value is wdMove.

MoveEnd

Moves the ending character position of a range or selection. This method returns an integer that indicates the number of units the range or selection actually moved, or it returns 0 (zero) if the move was unsuccessful.

expression.MoveEnd(Unit, Count)

expression Required. An expression that returns a Range or Selection object.

Unit    Optional WdUnits . The unit by which to move the ending character position.

Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow or wdTable.

If expression returns a Selection object, wdLine can also be used. The default value is wdCharacter.

Count    Optional Variant. The number of units to move. If this number is positive, the ending character position is moved forward in the document. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both character positions move together. The default value is 1.

MoveEndUntil

Moves the end position of the specified range or selection until any of the specified characters are found in the document. If the movement is forward in the document, the range or selection is expanded.

Remarks

This method returns the number of characters by which the end position of the specified range or selection was moved, as a Long value. If Count is greater than 0 (zero), this method returns the number of characters moved plus 1. If Count is less than 0 (zero), this method returns the number of characters moved minus 1. If no Cset characters are found, the range or selection isn't changed and the method returns 0 (zero). If the end position is moved backward to a point that precedes the original start position, the start position is set to the new ending position.

expression.MoveEndUntil(Cset, Count)

expression Required. An expression that returns a Range or Selection object.

Cset    Required Variant. One or more characters. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the specified range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the range or selection is moved forward in the document. If it's a negative number, the range or selection is moved backward. The default value is wdForward.

MoveEndWhile

Moves the ending character position of a range or selection while any of the specified characters are found in the document.

Remarks

While any character in Cset is found, the end position of the specified range or selection is moved. This method returns the number of characters that the end position of the range or selection moved as a Long value. If no Cset characters are found, the range or selection isn't changed and the method returns 0 (zero). If the end position is moved backward to a point that precedes the original start position, the start position is set to the new end position.

expression.MoveEndWhile(Cset, Count)

expression Required. An expression that returns a Range or Selection object.

Cset    Required Variant. One or more characters. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the range or selection is moved forward in the document. If it's a negative number, the range or selection is moved backward. The default value is wdForward.

MoveLeft

Moves the selection to the left and returns the number of units it's been moved.

expression.MoveLeft(Unit, Count, Extend)

expression Required. An expression that returns a Selection object.

Unit    Optional WdUnits . The unit by which the selection is to be moved.

Can be one of the following WdUnits constants. wdCell, wdCharacter, wdWord or wdSentence.

The default value is wdCharacter.

Count    Optional Variant. The number of units the selection is to be moved. The default value is 1.

Extend    Optional Variant. Can be either wdMove or wdExtend. If wdMove is used, the selection is collapsed to the end point and moved to the left. If wdExtend is used, the selection is extended to the left. The default value is wdMove.

Remarks

When the Unit is wdCell, the Extend argument will only be wdMove.

MoveRight

Moves the selection to the right and returns the number of units it's been moved.

expression.MoveRight(Unit, Count, Extend)

expression Required. An expression that returns a Selection object.

Unit    Optional WdUnits . The unit by which the selection is to be moved.

Can be one of the following WdUnits constants. wdCell, wdCharacter, wdWord or wdSentence. The default value is wdCharacter.

Count    Optional Variant. The number of units the selection is to be moved. The default value is 1.

Extend    Optional Variant. Can be either wdMove or wdExtend. If wdMove is used, the selection is collapsed to the end point and moved to the right. If wdExtend is used, the selection is extended to the right. The default value is wdMove.

Remarks

When the Unit is wdCell, the Extend argument will only be wdMove.

MoveStart

Moves the start position of the specified range or selection. This method returns an integer that indicates the number of units by which the start position or the range or selection actually moved, or it returns 0 (zero) if the move was unsuccessful.

expression.MoveStart(Unit, Count)

expression Required. An expression that returns a Range or Selection object.

Unit    Optional WdUnits . The unit by which start position of the specified range or selection is to be moved.

Can be one of the following WdUnits constants. wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow or wdTable.

If expression returns a Selection object, you can also use wdLine. The default value is wdCharacter.

Count    Optional Variant. The maximum number of units by which the specified range or selection is to be moved. If Count is a positive number, the start position of the range or selection is moved forward in the document. If it's a negative number, the start position is moved backward. If the start position is moved forward to a position beyond the end position, the range or selection is collapsed and both the start and end positions are moved together. The default value is 1.

MoveStartUntil

Moves the start position of the specified range or selection until one of the specified characters is found in the document. If the movement is backward through the document, the range or selection is expanded.

Remarks

This method returns the number of characters by which the start position of the specified range or selection moved, as a Long value. If Count is greater than 0 (zero), this method returns the number of characters moved plus 1. If Count is less than 0 (zero), this method returns the number of characters moved minus 1. If no Cset characters are found, the specified range or selection isn't changed and the method returns 0 (zero). If the start position is moved forward to a point beyond the end position, the range or selection is collapsed and both the start and end positions are moved together.

expression.MoveStartUntil(Cset, Count)

expression Required. An expression that returns an object in the Applies To list.

Cset    Required Variant. One or more characters. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the specified range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the range or selection is moved forward in the document. If it's a negative number, the range or selection is moved backward. The default value is wdForward.

MoveStartWhile

Moves the start position of the specified range or selection while any of the specified characters are found in the document.

Remarks

While any character in Cset is found, the start position of the range or selection is moved. This method returns the number of characters that the start position of the range or selection moved as a Long value. If not Cset characters are found, the range or selection isn't changed and the method returns 0 (zero). If the start position is moved forward to a position beyond the original end position, the end position is set to the new start position.

expression.MoveStartWhile(Cset, Count)

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

Cset    Required Variant. One or more characters. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the specified range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the range or selection is moved forward in the document. If it's a negative number, the range or selection is moved backward. The default value is wdForward.

MoveUntil

Moves the specified range or selection until one of the specified characters is found in the document.

expression.MoveUntil(Cset, Count)

expression Required. An expression that returns a Range of Selection object.

Cset    Required Variant. One or more characters. If any character in Cset is found before the Count value expires, the specified range or selection is positioned as an insertion point immediately before that character. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the specified range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the range or selection is moved forward in the document, beginning at the end position. If it's a negative number, the range or selection is moved backward, beginning at the start position. The default value is wdForward.

Remarks

This method returns the number of characters by which the specified range or selection was moved, as a Long value. If Count is greater than 0 (zero), this method returns the number of characters moved plus one. If Count is less than 0 (zero), this method returns the number of characters moved minus one. If no Cset characters are found, the range or selection isn't not changed and the method returns 0 (zero).

MoveUp

Moves the selection up and returns the number of units it's been moved.

Note  The wdWindow constant can be used to move to the top or bottom of the active window. Regardless of the value of Count (greater than 1 or less than 1), the wdWindow constant moves only one unit. Use the wdScreen constant to move more than one screen.

expression.MoveUp(Unit, Count, Extend)

expression Required. An expression that returns an object in the Applies To list.

Unit    Optional Variant. The unit by which to move the selection. Can be one of the following WdUnits constants: wdLine, wdParagraph, wdWindow or wdScreen. The default value is wdLine.

Count    Optional Variant. The number of units the selection is to be moved. The default value is 1.

Extend    Optional Variant. Can be either wdMove or wdExtend. If wdMove is used, the selection is collapsed to the end point and moved up. If wdExtend is used, the selection is extended up. The default value is wdMove.

MoveWhile

Moves the specified range or selection while any of the specified characters are found in the document.

Remarks

While any character in Cset is found, the specified range or selection is moved. The resulting Range or Selection object is positioned as an insertion point after whatever Cset characters were found. This method returns the number of characters by which the specified range or selection was moved, as a Long value. If no Cset characters are found, the range or selection isn't changed and the method returns 0 (zero).

expression.MoveWhile(Cset, Count)

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

Cset    Required Variant. One or more characters. This argument is case sensitive.

Count    Optional Variant. The maximum number of characters by which the specified range or selection is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the specified range or selection is moved forward in the document, beginning at the end position. If it's a negative number, the range or selection is moved backward, beginning at the start position. The default value is wdForward.

Next

Returns a Range object that represents the specified unit relative to the specified selection or range.

expression.Next(Unit, Count)

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

Unit   Optional Variant. The type of units by which to count. Can be any WdUnits constant.

Count   Optional Variant. The number of units by which you want to move ahead. The default value is one.

Remarks

If the Range or Selection is just before the specified Unit, the Range or Selection is moved to the following unit. For example, if the Selection is just before a word, the following instruction moves the Selection forward to the following word.

NextField

Selects the next field. If a field is found, this method returns a Field object; if not, it returns Nothing.

NextRevision

Locates and returns the next tracked change as a Revision object. The changed text becomes the current selection. Use the properties of the resulting Revision object to see what type of change it is, who made it, and so forth. Use the methods of the Revision object to accept or reject the change.

expression.NextRevision(Wrap)

expression Required. An expression that returns a Selection object.

Wrap    Optional Variant. True to continue searching for a revision at the beginning of the document when the end of the document is reached. The default value is False.

Remarks

If there are no tracked changes to be found, the current selection remains unchanged.

NextSubdocument

Moves the range or selection to the next subdocument. If there isn't another subdocument, an error occurs.

Paste

Inserts the contents of the Clipboard at the specified range or selection. If you don't want to replace the contents of the range or selection, use the Collapse method before using this method.

expression.Paste

expression Required. An expression that returns a Range or Selection object.

Remarks

When this method is used with a range object, the range expands to include the contents of the Clipboard. When this method is used with a selection object, the selection doesn't expand to include the Clipboard contents; instead, the selection is positioned after the pasted Clipboard contents.

PasteAndFormat

Pastes the selected table cells and formats them as specified.

expression.PasteAndFormat(Type)

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

Type   Required WdRecoveryType . The type of formatting to use when pasting the selected table cells.

PasteAppendTable

Merges pasted cells into an existing table by inserting the pasted rows between the selected rows. No cells are overwritten.

PasteAsNestedTable

Pastes a cell or group of cells as a nested table into the selected range.

expression.PasteAsNestedTable

expression Required. An expression that returns a Range or Selection object.

Remarks

You can use PasteAsNestedTable only if the Clipboard contains a cell or group of cells and the selected range is a cell or group of cells in the current document.

PasteExcelTable

Pastes and formats a Microsoft Excel table.

expression.PasteExcelTable(LinkedToExcel, WordFormatting, RTF)

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

LinkedToExcel   Required Boolean. True links the pasted table to the original Excel file so that changes made to the Excel file are reflected in Microsoft Word.

WordFormatting   Required Boolean. True formats the table using the formatting in the Word document. False formats the table according to the original Excel file.

RTF   Required Boolean. True pastes the Excel table using Rich Text Format (RTF). False pastes the Excel table as HTML.

PasteFormat

Applies formatting copied with the CopyFormat method to the selection. If a paragraph mark was selected when the CopyFormat method was used, Word applies paragraph formatting in addition to character formatting.

PasteSpecial

Inserts the contents of the Clipboard. Unlike with the Paste method, with PasteSpecial you can control the format of the pasted information and (optionally) establish a link to the source file (for example, a Microsoft Excel worksheet).

Note  If you don't want to replace the contents of the specified range or selection, use the Collapse method before you use this method. When you use this method, the range or selection doesn't expand to include the contents of the Clipboard.

expression.PasteSpecial(IconIndex, Link, Placement, DisplayAsIcon, DataType, IconFileName, IconLabel)

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

IconIndex   Optional Variant. If DisplayAsIcon is True, this argument is a number that corresponds to the icon you want to use in the program file specified by IconFilename. Icons appear in the Change Icon dialog box (Insert menu, Object command, Create New tab): 0 (zero) corresponds to the first icon, 1 corresponds to the second icon, and so on. If this argument is omitted, the first (default) icon is used.

Link   Optional Variant. True to create a link to the source file of the Clipboard contents. The default value is False.

Placement   Optional Variant. Can be either of the following WdOLEPlacement constants: wdFloatOverText or wdInLine. The default value is wdInLine.

DisplayAsIcon   Optional Variant.Optional Variant. True to display the link as an icon. The default value is False.

DataType   Optional Variant. A format for the Clipboard contents when they're inserted into the document. WdPasteDataType.

IconFileName   Optional Variant.If DisplayAsIcon is True, this argument is the path and file name for the file in which the icon to be displayed is stored.

IconLabel   Optional Variant.If DisplayAsIcon is True, this argument is the text that appears below the icon.

Previous

Returns a Range object relative to the specified selection or range.

Note  If the Range or Selection is just after the specified Unit, the Range or Selection is moved to the previous unit. For example, if the Selection is just after a word (before the trailing space), the following instruction moves the Selection backwards to the previous word.

Selection.Previous(Unit:=wdWord, Count:=1).Select

expression.Previous(Unit, Count)

PreviousField

Selects the previous field. If a field is found, this method returns a Field object; if not, it returns Nothing.

PreviousRevision

Locates and returns the previous tracked change as a Revision object.

expression.PreviousRevision(Wrap)

expression Required. An expression that returns a Selection object.

Wrap    Optional Variant. True to continue searching for a revision at the end of the document when the beginning of the document is reached. The default value is False.

PreviousSubdocument

Moves the range or selection to the previous subdocument. If there isn't another subdocument, an error occurs.

RtlPara

Sets the reading order and alignment of the specified paragraphs to right-to-left.

expression.RtlPara

expression Required. An expression that returns a Selection object.

Remarks

For all selected paragraphs, this method sets the reading order to right-to-left. If a paragraph with a left-to-right reading order is also left-aligned, this method reverses its reading order and sets its paragraph alignment to right-aligned.

Use the ReadingOrder property to change the reading order without affecting paragraph alignment.

For more information on using Microsoft Word with right-to-left languages, see Word features for right-to-left languages.

RtlRun

Sets the reading order and alignment of the specified run to right-to-left.

expression.RtlRun

expression Required. An expression that returns a Selection object.

Remarks

For the specified run, this method sets the reading order to right-to-left. If a paragraph in the run with a left-to-right reading order is also left-aligned, this method reverses its reading order and sets its paragraph alignment to right-aligned.

Use the ReadingOrder property to change the reading order without affecting paragraph alignment.

For more information on using Microsoft Word with right-to-left languages, see Word features for right-to-left languages.

Select

Selects the specified object.

Note  After using this method, use the Selection property to work with the selected items. For more information, see Working with the Selection object .

SelectCell

Selects the entire cell containing the current selection. To use this method, the current selection must be contained within a single cell.

SelectColumn

Selects the column that contains the insertion point, or selects all columns that contain the selection. If the selection isn't in a table, an error occurs.

SelectCurrentAlignment

Extends the selection forward until text with a different paragraph alignment is encountered.

expression.SelectCurrentAlignment

expression Required. An expression that returns a Selection object.

Remarks

There are four types of paragraph alignment: left, centered, right, and justified.

SelectCurrentColor

Extends the selection forward until text with a different color is encountered.

SelectCurrentFont

Extends the selection forward until text in a different font or font size is encountered.

SelectCurrentIndent

Extends the selection forward until text with different left or right paragraph indents is encountered.

SelectCurrentSpacing

Extends the selection forward until a paragraph with different line spacing is encountered.

SelectCurrentTabs

Extends the selection forward until a paragraph with different tab stops is encountered.

SelectRow

Selects the row that contains the insertion point, or selects all rows that contain the selection. If the selection isn't in a table, an error occurs.

SetRange

Sets the starting and ending character positions for the range or selection.

Note  Character position values start at the beginning of the story, with the first value being 0 (zero). All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed.

expression.SetRange(Start, End)

expression Required. An expression that returns a Range or Selection object.

Start    Required Long. The starting character position of the range or selection.

End    Required Long. The ending character position of the range or selection.

Remarks

The SetRange method redefines the starting and ending positions of an existing Selection or Range object. This method differs from the Range method, which is used to create a range, given a starting and ending position.

Shrink

Selection object: Shrinks the selection to the next smaller unit of text. The progression is as follows: entire document, section, paragraph, sentence, word, insertion point.

ShrinkDiscontiguous Selection

Deselects all but the most recently selected text when a selection contains multiple, unconnected selections.

Sort

Sorts the paragraphs in the specified range or selection.

expression.Sort(ExcludeHeader, FieldNumber, SortFieldType, SortOrder, FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3, SortOrder3, SortColumn, Separator, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID)

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

ExcludeHeader   Optional Variant. True to exclude the first row or paragraph header from the sort operation. The default value is False.

FieldNumber, FieldNumber2   , FieldNumber3Optional Variant. The fields to sort by. Microsoft Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.

SortFieldType, SortFieldType2, SortFieldType3   Optional Variant. The respective sort types for FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortFieldType constants.

The default value is wdSortFieldAlphanumeric. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

SortOrder, SortOrder2, SortOrder3   Optional Variant. The sorting order to use when sorting FieldNumber, FieldNumber2, and FieldNumber3. Can be one WdSortOrder constant.

SortColumn   Optional Variant. True to sort only the column specified by the Range or Selection object.

Separator   Optional Variant. The type of field separator. Can be one of the WdSortSeparator constants.

CaseSensitive   Optional Variant. True to sort with case sensitivity. The default value is False.

BidiSort   Optional Variant. True to sort based on right-to-left language rules. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

IgnoreThe   Optional Variant. True to ignore the Arabic character alef lam when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

IgnoreKashida   Optional Variant. True to ignore kashidas when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

IgnoreDiacritics   Optional Variant. True to ignore bidirectional control characters when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

IgnoreHe   Optional Variant. True to ignore the Hebrew character he when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

LanguageID   Optional Variant. LanguageIDOptional Variant. Specifies the sorting language. Can be one of the WdLanguageID constants. Refer to the Object Browser for a list of the WdLanguageID constants.

SubFieldNumber, SubFieldNumber2, SubFieldNumber3   Optional Variant. (Applies to the Selection object only.)

SortAscending

Sorts paragraphs or table rows in ascending alphanumeric order. The first paragraph or table row is considered a header record and isn't included in the sort. Use the Sort method to include the header record in a sort.

Note  This method offers a simplified form of sorting intended for mail merge data sources that contain columns of data. For most sorting tasks, use the Sort method.

SortDescending

Sorts paragraphs or table rows in descending alphanumeric order. The first paragraph or table row is considered a header record and isn't included in the sort. Use the Sort method to include the header record in a sort.

Note  This method offers a simplified form of sorting intended for mail-merge data sources that contain columns of data. For most sorting tasks, use the Sort method.

SplitTable

Inserts an empty paragraph above the first row in the selection. If the selection isn't in the first row of the table, the table is split into two tables.

Note  If the selection isn't in a table, an error occurs.

StartOf

Moves or extends the start position of the specified range or selection to the beginning of the nearest specified text unit. This method returns a Long that indicates the number of characters by which the range or selection was moved or extended. The method returns a negative number if the movement is backward through the document.

expression.StartOf(Unit, Extend)

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

Unit   Optional WdUnits . The unit by which the start position of the specified range or selection is to be moved.

Extend   Optional WdMovement .

Remarks

If the beginning of the specified range or selection is already at the beginning of the specified unit, this method doesn't move or extend the range or selection. For example, if the selection is at the beginning of a line, the following example returns 0 (zero) and doesn't change the selection.

ToggleCharacterCode

Switches a selection between a Unicode character and its corresponding hexadecimal value.

TypeBackspace

Deletes the character preceding a collapsed selection (an insertion point). If the selection isn't collapsed to an insertion point, the selection is deleted.

Note  This method corresponds to functionality of the BACKSPACE key.

TypeParagraph

Inserts a new, blank paragraph. If the selection isn't collapsed to an insertion point, it's replaced by the new paragraph. Use the InsertParagraphAfter or InsertParagraphBefore method to insert a new paragraph without deleting the contents of the selection.

Note  This method corresponds to the functionality of the ENTER key.

TypeText

Inserts the specified text. If the ReplaceSelection property is True, the selection is replaced by the specified text. If ReplaceSelection is False, the specified text is inserted before the selection.

expression.TypeText(Text)

expression Required. An expression that returns a Selection object.

Text    Required String. The text to be inserted.

WholeStory

Expands a range or selection to include the entire story.

expression.WholeStory

expression Required. An expression that returns a Range or Selection object.

Remarks

The following instructions, where myRange is a valid Range object, are functionally equivalent:

myRange.WholeStory

myRange.Expand Unit:=wdStory

Using the Selection Object

Use the Selection property to return the Selection object. If no object qualifier is used with the Selection property, Word returns the selection from the active pane of the active document window. The following example copies the current selection from the active document.

Selection.Copy

The following example cuts the selection from the third document in the Documents collection. The document doesn't have to be active to access its current selection.

Documents(3).ActiveWindow.Selection.Cut

The following example copies the selection from the first pane of the active document and pastes it into the second pane.

ActiveDocument.ActiveWindow.Panes(1).Selection.Copy
ActiveDocument.ActiveWindow.Panes(2).Selection.Paste

The Text property is the default property of the Selection object. Use this property to set or return the text in the current selection. The following example assigns the text in the current selection to the variable strTemp, removing the last character if it is a paragraph mark.

Dim strTemp as String
strTemp = Selection.Text
If Right(strTemp, 1) = vbCr Then _
    strTemp = Left(strTemp, Len(strTemp) - 1)

The Selection object has various methods and properties with which you can collapse, expand, or otherwise change the current selection. The following example moves the insertion point to the end of the document and selects the last three lines.

Selection.EndOf Unit:=wdStory, Extend:=wdMove
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend

The Selection object has various methods and properties with which you can edit selected text in a document. The following example selects the first sentence in the active document and replaces it with a new paragraph.

Options.ReplaceSelection = True
ActiveDocument.Sentences(1).Select
Selection.TypeText "Material below is confidential."
Selection.TypeParagraph

The following example cuts the last paragraph of the first document in the Documents collection and pastes it at the beginning of the second document.

With Documents(1)
    .Paragraphs.Last.Range.Select
    .ActiveWindow.Selection.Cut
End With

With Documents(2).ActiveWindow.Selection
    .StartOf Unit:=wdStory, Extend:=wdMove
    .Paste
End With

The Selection object has various methods and properties with which you can change the formatting of the current selection. The following example changes the font of the current selection from Times New Roman to Tahoma.

If Selection.Font.Name = "Times New Roman" Then _
     Selection.Font.Name = "Tahoma"

Use properties like Flags , Information , and Type to return information about the current selection. You could use the following example in a procedure to determine if there were anything actually selected in the active document; if not, the rest of the procedure would be skipped.

If Selection.Type = wdSelectionIP Then
    MsgBox Prompt:="You haven't selected any text! Exiting procedure..."
    Exit Sub
End If

Remarks

Even when a selection is collapsed to an insertion point, it isn't necessarily empty. For example, the Text property will still return the character to the right of the insertion point; this character also appears in the Characters collection of the Selection object. However, calling methods like Cut or Copy from a collapsed selection will cause an error.

It's possible for the user to select a region in a document that doesn't represent contiguous text (for example, when using the ALT key with the mouse). Because the behavior of such a selection can be unpredictable, you may want to include a step in your code that checks the Type property of a selection before performing any operations on it (Selection.Type = wdSelectionBlock). Similarly, selections that include table cells can also lead to unpredictable behavior. The Information property will tell you if a selection is inside a table (Selection.Information(wdWithinTable) = True). The following example determines if a selection is normal (in other words, it isn't a row or column in a table, it isn't a vertical block of text, and so forth); you could use it to test the current selection before performing any operations on it.

If Selection.Type <> wdSelectionNormal Then
    MsgBox Prompt:="Not a valid selection! Exiting procedure..."
    Exit Sub
End If

Because Range objects share many of the same methods and properties as Selection objects, using Range objects is preferable for manipulating a document when there isn't a reason to physically change the current selection. For more information on Selection and Range objects, see Working with the Selection object and Working with Range objects .

Working with the Selection Object

When you work on a document in Word, you usually select text and then perform an action, such as formatting the text or typing text. In Visual Basic, it is usually not necessary to select text before modifying the text. Instead, you create a Range object that refers to a specific portion of the document. For information on defining Range objects, see Working with Range objects . However, when you want your code to respond to or change the selection, you can do so with the Selection object.

The Select method activates an object. For example, the following instruction selects the first word in the active document.

Sub SelectFirstWord()
    ActiveDocument.Words(1).Select
End Sub

For more information, see Selecting text in a document .

The Selection property returns a Selection object that represents the active selection in a document window pane. There can only be one Selection object per document window pane and only one Selection object can be active. For example, the following example changes the paragraph formatting of the paragraphs in the selection.

Sub FormatSelection()
    Selection.Paragraphs.LeftIndent = InchesToPoints(0.5)
End Sub

For example, the following example inserts the word "Hello" after the selection.

Sub InsertTextAfterSelection()
    Selection.InsertAfter Text:="Hello "
End Sub

The following example applies bold formatting to the selected text.

Sub BoldSelectedText()
    Selection.Font.Bold = True
End Sub

The macro recorder will often create a macro that uses the Selection property. The following example was created using the macro recorder. The macro applies bold formatting to the first two words in the document.

Sub Macro()
    Selection.HomeKey Unit:=wdStory
    Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
    Selection.Font.Bold = wdToggle
End Sub

The following example accomplishes the same task without using the Selection property.

Sub WorkingWithRanges()
    ActiveDocument.Range(Start:=0, _
    End:=ActiveDocument.Words(2).End).Bold = True
End Sub

Enumerations and Constants

Enumeration WdInformation

Constant

Value

 Description

wdActiveEndAdjustedPageNumber

1

Returns the number of the page that contains the active end of the specified selection or range. If you set a starting page number or make other manual adjustments, returns the adjusted page number (unlike wdActiveEndPageNumber).

wdActiveEndPageNumber

3

Returns the number of the page that contains the active end of the specified selection or range, counting from the beginning of the document. Any manual adjustments to page numbering are disregarded (unlike wdActiveEndAdjustedPageNumber).

wdActiveEndSectionNumber

2

Returns the number of the section that contains the active end of the specified selection or range.

wdAtEndOfRowMarker

31

Returns True if the specified selection or range is at the end-of-row mark in a table.

wdCapsLock

21

Returns True if Caps Lock is in effect.

wdEndOfRangeColumnNumber

17

Returns the table column number that contains the end of the specified selection or range.

wdEndOfRangeRowNumber

14

Returns the table row number that contains the end of the specified selection or range.

wdFirstCharacterColumnNumber

9

Returns the character position of the first character in the specified selection or range. If the selection or range is collapsed, the character number immediately to the right of the range or selection is returned (this is the same as the character column number displayed in the status bar after "Col").

wdFirstCharacterLineNumber

10

Returns the character position of the first character in the specified selection or range. If the selection or range is collapsed, the character number immediately to the right of the range or selection is returned (this is the same as the character line number displayed in the status bar after "Ln").

wdFrameIsSelected

11

Returns True if the selection or range is an entire frame or text box.

wdHeaderFooterType

33

Returns a value that indicates the type of header or footer that contains the specified selection or range, as shown in the following table.

wdHorizontalPositionRelativeToPage

5

Returns the horizontal position of the specified selection or range; this is the distance from the left edge of the selection or range to the left edge of the page measured in points (1 point = 20 twips, 72 points = 1 inch). If the selection or range isn't within the screen area, returns 1.

wdHorizontalPositionRelativeToTextBoundary

7

Returns the horizontal position of the specified selection or range relative to the left edge of the nearest text boundary enclosing it, in points (1 point = 20 twips, 72 points = 1 inch). If the selection or range isn't within the screen area, returns - 1.

wdInClipboard

38

For information about this constant, consult the language reference Help included with Microsoft Office Macintosh Edition.

wdInCommentPane

26

Returns True if the specified selection or range is in a comment pane.

wdInEndnote

36

Returns True if the specified selection or range is in an endnote area in print layout view or in the endnote pane in normal view.

wdInFootnote

35

Returns True if the specified selection or range is in a footnote area in print layout view or in the footnote pane in normal view.

wdInFootnoteEndnotePane

25

Returns True if the specified selection or range is in the footnote or endnote pane in normal view or in a footnote or endnote area in print layout view. For more nformation, see the descriptions of wdInFootnote and wdInEndnote in the preceding paragraphs.

wdInHeaderFooter

28

Returns True if the selection or range is in the header or footer pane or in a header or footer in print layout view.

Value

Type of header or footer

- 1

None (the selection or range isn't in a header or footer)

0 (zero)

Even page header

1

Odd page header (or the only header, if there aren't odd and even headers)

2

Even page footer

3

Odd page footer (or the only footer, if there aren't odd and even footers)

4

First page header

5

First page footer

 

wdInMasterDocument

34

Returns True if the selection or range is in a master document (that is, a document that contains at least one subdocument).

wdInWordMail

37

Returns True if the selection or range is in the header or footer pane or in a header or footer in print layout view.

Value

Location

0(zero)

The selection or range isn't in an e-mail message.

1

The selection or range is in an e-mail message you are sending.

2

The selection or range is in an e-mail you are reading.

 

wdMaximumNumberOfColumns

18

Returns the greatest number of table columns within any row in the selection or range.

wdMaximumNumberOfRows

15

Returns the greatest number of table rows within the table in the specified selection or range.

wdNumberOfPagesInDocument

4

Returns the number of pages in the document associated with the selection or range.

wdNumLock

22

Returns True if Num Lock is in effect.

wdOverType

23

Returns True if Overtype mode is in effect. The Overtype property can be used to change the state of the Overtype mode.

wdReferenceOfType

32

Returns a value that indicates where the selection is in relation to a footnote, endnote, or comment reference, as shown in the following table.

Value

Description

1

The selection or range includes but isn't limited to a footnote, endnote, or comment reference.

0 (zero)

The selection or range isn't before a footnote, endnote, or comment reference.

1

The selection or range is before a footnote reference.

2

The selection or range is before an endnote reference.

3

The selection or range is before a comment reference.

 

wdRevisionMarking

24

Returns True if change tracking is in effect.

wdSelectionMode

20

Returns a value that indicates the current selection mode, as shown in the following table.

Value

Selection mode

0 (zero)

Normal selection

1

Extended selection ("EXT" appears on the status bar)

2

Column selection. ("COL" appears on the status bar)

 

wdStartOfRangeColumnNumber

16

Returns the table column number that contains the beginning of the selection or range.

wdStartOfRangeRowNumber

13

Returns the table row number that contains the beginning of the selection or range.

wdVerticalPositionRelativeToPage

6

Returns the vertical position of the selection or range; this is the distance from the top edge of the selection to the top edge of the page measured in points (1 point = 20 twips, 72 points = 1 inch). If the selection isn't visible in the document window, returns 1.

wdVerticalPositionRelativeToTextBoundary

8

Returns the vertical position of the selection or range relative to the top edge of the nearest text boundary enclosing it, in points (1 point = 20 twips, 72 points = 1 inch). This is useful for determining the position of the insertion point within a frame or table cell. If the selection isn't visible, returns 1.

wdWithInTable

12

Returns True if the selection is in a table.

wdZoomPercentage

19

Returns the current percentage of magnification as set by the Percentage property.

Enumeration WdSelectionFlags

Constant

Value

wdSelActive

8

wdSelAtEOL

2

wdSelOvertype

4

wdSelReplace

16

wdSelStartActive

1

Enumeration WdTextOrientation

Constant

Value

wdTextOrientationDownward

3

wdTextOrientationHorizontal

0

wdTextOrientationHorizontalRotatedFarEast

4

wdTextOrientationUpward

2

wdTextOrientationVerticalFarEast

1

Enumeration WdStoryType

Constant

Value

wdCommentsStory

4

wdEndnoteContinuationNoticeStory

17

wdEndnoteContinuationSeparatorStory

16

wdEndnoteSeparatorStory

15

wdEndnotesStory

3

wdEvenPagesFooterStory

8

wdEvenPagesHeaderStory

6

wdFirstPageFooterStory

11

wdFirstPageHeaderStory

10

wdFootnoteContinuationNoticeStory

14

wdFootnoteContinuationSeparatorStory

13

wdFootnoteSeparatorStory

12

wdFootnotesStory

2

wdMainTextStory

1

wdPrimaryFooterStory

9

wdPrimaryHeaderStory

7

wdTextFrameStory

5

Enumeration WdSelectionType

Constant

Value

wdNoSelection

0

wdSelectionBlock

6

wdSelectionColumn

4

wdSelectionFrame

3

wdSelectionInlineShape

7

wdSelectionIP

1

wdSelectionNormal

2

wdSelectionRow

5

wdSelectionShape

8

Enumeration WdTableFieldSeparator

Constant

Value

wdSeparateByCommas

2

wdSeparateByDefaultListSeparator

3

wdSeparateByParagraphs

0

wdSeparateByTabs

1

Enumeration WdTableFormat

Constant

Value

wdTableFormat3DEffects1

32

wdTableFormat3DEffects2

33

wdTableFormat3DEffects3

34

wdTableFormatClassic1

4

wdTableFormatClassic2

5

wdTableFormatClassic3

6

wdTableFormatClassic4

7

wdTableFormatColorful1

8

wdTableFormatColorful2

9

wdTableFormatColorful3

10

wdTableFormatColumns1

11

wdTableFormatColumns2

12

wdTableFormatColumns3

13

wdTableFormatColumns4

14

wdTableFormatColumns5

15

wdTableFormatContemporary

35

wdTableFormatElegant

36

wdTableFormatGrid1

16

wdTableFormatGrid2

17

wdTableFormatGrid3

18

wdTableFormatGrid4

19

wdTableFormatGrid5

20

wdTableFormatGrid6

21

wdTableFormatGrid7

22

wdTableFormatGrid8

23

wdTableFormatList1

24

wdTableFormatList2

25

wdTableFormatList3

26

wdTableFormatList4

27

wdTableFormatList5

28

wdTableFormatList6

29

wdTableFormatList7

30

wdTableFormatList8

31

wdTableFormatNone

0

wdTableFormatProfessional

37

wdTableFormatSimple1

1

wdTableFormatSimple2

2

wdTableFormatSimple3

3

wdTableFormatSubtle1

38

wdTableFormatSubtle2

39

wdTableFormatWeb1

40

wdTableFormatWeb2

41

wdTableFormatWeb3

42

Enumeration WdAutoFitBehavior

Constant

Value

wdAutoFitContent

1

wdAutoFitFixed

0

wdAutoFitWindow

2

Enumeration WdDefaultTableBehavior

Constant

Value

Description

wdWord8TableBehavior

0

Disables AutoFit. Default.

wdWord9TableBehavior

1

wdWord9TableBehavior Enables AutoFit.

Enumeration WdUnits

Used with the following Selection methods:

Delete
EndKey
HomeKey
EndOf StartOf
Expand
Next
Move
MoveDown
MoveUp
MoveStart
MoveEnd
MoveLeft
MoveRight

Constant

Value

wdCell

12

wdCharacter

1

wdCharacterFormatting

13

wdColumn

9

wdItem

16

wdLine (available only for Selection object)

5

wdParagraph

4

wdParagraphFormatting

14

wdRow

10

wdScreen

7

wdSection

8

wdSentence

3

wdStory

6

wdTable

15

wdWindow

11

wdWord

2

Enumeration WdGoToItem

Constant Value
wdGoToBookmark -1
wdGoToComment 6
wdGoToEndnote 5
wdGoToEquation 10
wdGoToField 7
wdGoToFootnote 4
wdGoToGrammaticalError 14
wdGoToGraphic 8
wdGoToHeading 11
wdGoToLine 3
wdGoToObject 9
wdGoToPage 1
wdGoToPercent 12
wdGoToProofreadingError 15
wdGoToSection 0
wdGoToSpellingError 13
wdGoToTable 2

 Enumeration WdGoToDirection

Constant Value
wdGoToAbsolute 1
wdGoToFirst 1
wdGoToLast -1
wdGoToNext 2
wdGoToPrevious 3
wdGoToRelative 2

Enumeration WdEditorType

Constant Value Description
wdEditorCurrent -6 Represents the current user of the document.
wdEditorEditors -5 Represents the Editors group for documents that use Information Rights Management.
wdEditorEveryone -1 Represents all users who open a document.
wdEditorOwners -4 Represents the Owners group for documents that use Information Rights Management.

 Enumeration WdInsertCells

Constant

Value

Description

wdInsertCellsEntireColumn

3

Inserts an entire column to the left of the column that contains the selection.

wdInsertCellsEntireRow

2

Inserts an entire row above the row that contains the selection.

wdInsertCellsShiftDown

1

Inserts new cells above the selected cells.

wdInsertCellsShiftRight

0

Insert new cells to the left of the selected cells.

Enumeration WdReferenceType

Constant Value
wdRefTypeBookmark 2
wdRefTypeEndnote 4
wdRefTypeFootnote 3
wdRefTypeHeading 1
wdRefTypeNumberedItem 0

Enumeration WdCaptionLabelID

Constant

Value

wdCaptionEquation

-3

wdCaptionFigure

-1

wdCaptionTable

-2

Enumeration WdReferenceKind

Constant

Value

wdContentText

-1

wdEndnoteNumber

6

wdEndnoteNumberFormatted

17

wdEntireCaption

2

wdFootnoteNumber

5

wdFootnoteNumberFormatted

16

wdNumberFullContext

-4

wdNumberNoContext

-3

wdNumberRelativeContext

-2

wdOnlyCaptionText

4

wdOnlyLabelAndNumber

3

wdPageNumber

7

wdPosition

15

Enumeration WdRecoveryType

Constant

Value

Description

wdChart

14

Pastes a Microsoft Excel chart as an embedded OLE object.

wdChartLinked

15

Pastes an Excel chart and links it to the original Excel spreadsheet.

wdChartPicture

13

Pastes an Excel chart as a picture.

wdFormatOriginalFormatting

16

Preserves original formatting of the pasted material.

wdFormatPlainText

22

Pastes as plain, unformatted text.

wdFormatSurroundingFormattingWithEmphasis

20

Matches the formatting of the pasted text to the formatting of surrounding text.

wdListCombineWithExistingList

24

Merges a pasted list with neighboring lists.

wdListContinueNumbering

7

Continues numbering of a pasted list from the list in the document.

wdListDontMerge

25

 

wdListRestartNumbering

8

Restarts numbering of a pasted list.

wdPasteDefault

0

 

wdSingleCellTable

6

Pastes a single cell table as a separate table.

wdSingleCellText

5

Pastes a single cell as text.

wdTableAppendTable

10

Merges pasted cells into an existing table by inserting the pasted rows between the selected rows.

wdTableInsertAsRows

11

Inserts a pasted table as rows between two rows in the target table.

wdTableOriginalFormatting

12

Pastes an appended table without merging table styles.

wdTableOverwriteCells

23

Pastes table cells and overwrites existing table cells.

Enumeration WdPasteDataType

Constant

Value

wdPasteBitmap

4

wdPasteDeviceIndependentBitmap

5

wdPasteEnhancedMetafile

9

wdPasteHTML

10

wdPasteHyperlink

7

wdPasteMetafilePicture

3

wdPasteOLEObject

0

wdPasteRTF

1

wdPasteShape

8

wdPasteText

2

The default format varies, depending on the contents of the Clipboard.

Enumeration WdSortFieldType

Constant

Value

wdSortFieldAlphanumeric

0

wdSortFieldDate

2

wdSortFieldJapanJIS

4

wdSortFieldKoreaKS

6

wdSortFieldNumeric

1

wdSortFieldStroke

5

wdSortFieldSyllable

3

Enumeration WdSortOrder

Constant

Value

wdSortOrderAscending (Default)

0

wdSortOrderDescending

1

Enumeration WdSortSeparator

Constant

Value

wdSortSeparateByCommas (Default)

1

wdSortSeparateByDefaultTableSeparator

2

wdSortSeparateByTabs

0

Enumeration WdMovementType

Constant

Value

wdExtend

1

wdMove

0

If you use wdMove, both ends of the range or selection are moved to the beginning of the specified unit. If you use wdExtend, the beginning of the range or selection is extended to the beginning of the specified unit. The default value is wdMove.

Enumeration WdBreakType

Constant

Value

wdColumnBreak

8

wdLineBreak

6

wdLineBreakClearLeft

9

wdLineBreakClearRight

10

wdPageBreak

7

wdSectionBreakContinuous

3

wdSectionBreakEvenPage

4

wdSectionBreakNextPage

2

wdSectionBreakOddPage

5

wdTextWrappingBreak

11

 


Etudes for Microsoft Word Programmers. Appendix. Object Selection.


Unless otherwise noted, all materials on this site are
2000-2009 Evgeny Akhundzhanov, All Rights Reserved Worldwide
Microsoft is in no way affiliated with, nor offers endorsement of, this site.
www.transcriber.ru | E-mail the Author