Finding Out Which Property or Method to Use
You can use the macro recorder to learn which methods or properties you need to accomplish a task in Word. The macro recorder is a tool that translates your actions into Visual Basic instructions. For example, if you turn on the macro recorder and open a document named "Examples.doc", the macro recorder records an instruction similar to the following.
Sub Macro1() ' ' Macro1 Macro ' Macro recorded 9/22/2000 by JeffSmith ' Documents.Open FileName:="Examples.doc", ConfirmConversions:=False, _ ReadOnly:=False, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", _ Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto End Sub
The Documents property returns the Documents collection and the Open method opens the specified file name. When you are first learning Visual Basic, using the macro recorder can help you learn which properties and methods you need to use to accomplish a task.
For more information, see Revising recorded Visual Basic macros.