OLE Automation: Specifying a Command Button from Visual BasicLast reviewed: February 6, 1998Article ID: Q105581 |
The information in this article applies to:
SUMMARYUsing a Microsoft Visual Basic application, it is possible to run a WordBasic instruction with command button parameters. Boolean "true" and "false" values are used to specify command buttons. For example:
ToolsMacro .Name = "MacroName", .RunTo use this instruction in a Visual Basic procedure, you would write:
WordObj.ToolsMacro "MacroName", TrueThe "True" value is the Visual Basic equivalent to choosing/specifying the Run command button. You can use the "False" value or omit a command button argument to not choose a command button. When calling WordBasic instructions from Visual Basic you must identify WordBasic arguments by position using commas as placeholders. The following Visual Basic procedure opens the Test macro for editing (the equivalent of ToolsMacro .Name = "Test", .Edit). WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Sub Command1_Click ()Dim WordObj As Object Set WordObj = CreateObject("Word.Basic") WordObj.ToolsMacro "Test", , True End SubIf you remove the comma before True, the instruction will run the Test macro. For example:
WordObj.ToolsMacro "Test", True |
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |