VBA Code

Application.Run [Template_Name).[Module_Name].[Macro_Name] 
Application.Run Normal.modCode.Macro1

The macro recorder creates a macro using the selection property although you can usually accomplish the same task with fewer instructions one or more using the Range objects


The visual interface for a Document object is the actual document itself although it does have a separate code module associated with it that contains any document specific event handlers.


Under each node in the Project Explorer labeled Microsoft Word Objects is a node labeled ThisDocument.


This node represents the document or template.
Activedocument refers to the document in focus
Word automatically provides a reference to the attached template.


If you have a shortcut key assigned to the wrong operation select (Tools > Customise) (Command tab). Locate the menu item you want to assign the shortcut to and select the keyboard button


Units when using the .move commands are wdCell, wdCharacter, wdWord, wdSentance, wdLine




If a method or property is available from the Range object but not from the Selection object (the Check Spelling method) use the Range property to return a Range Object from the Selection object


The Find action differs slightly depending on whether you return the Find object from the Selection object or Range object


If working with individual rows and columns in a table where tow or more adjacent cells have been merged, a run-time error may occur if you use selection.tables(1).rows(2). You can avoid this by first using the select column or select row method to select the whole columns or rows. Use the cells property with the Selection object to select individual cells.


Range objects are preferred to selection. Manipulating Range objects doesn't change the selected text and is faster than using the Selection object You can also define and use multiple Range objects, whereas you can only have one Selection object per document window


You can replace a Word command by giving a procedure the same name as the command or by creating a code module named after a Word command (for example, FileSave) with a subroutine named Main.




Be aware that if you minimise your Word document you cannot perform any formatting as a lot of the features . menu options are disabled.


Be aware using a With - End statement for selection does not work for all properties and methods (eg selection.copy and selection.paste)


The Insert commands never delete text, but they do extend the selection to include whatever is inserted


The Type commands may delete but they do keep the selection down to the insertion point.


Using Selections instead of Ranges will cut down your programming and debugging time significantly


Ranges may run faster than Selections in some cases, but not in all (and in most cases the time difference is minimal


If nothing is currently selected then the VBA code Selection.collapse wdcollapseend will not do anything



If the final paragraph mark in a document is selected then the VBA code Selection.collapse wdcollapseend will turn the paragraph mark into a single insertion point immediately infront of the final paragraph mark


If the selection extends over an end-of-cell marker, then the VBA code Selection.MoveEnd will select the entire cell


If the selection extends over an end-of-row marker, then the VBA code Selection.MoveEnd will select the whole row


If the selection goes beyond an end-of-row marker, then the VBA code Selection.MoveEnd will select the entire next row.


Word 2003

Security Level tab

Very High - This option was added in Word 2003.
High -
Medium -
Low -


Trusted Publishers


Word 2002

Security Level tab

High -
Medium -
Low -


Trusted Publishers


Word 2000

Security Level tab

High -
Medium -
Low -


Trusted Publishers



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext