Difference between revisions of "Microsoft KB Archive/105581"

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 23: Line 23:
 
== SUMMARY ==
 
== SUMMARY ==
  
Using a Microsoft Visual Basic application, it is possible to run a WordBasic instruction with command button parameters. Boolean &quot;true&quot; and &quot;false&quot; values are used to specify command buttons.<br />
+
Using 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.<br />
 
<br />
 
<br />
 
For example:
 
For example:
  
<pre class="CODESAMP">  ToolsMacro .Name = &quot;MacroName&quot;, .Run </pre>
+
<pre class="CODESAMP">  ToolsMacro .Name = "MacroName", .Run </pre>
 
To use this instruction in a Visual Basic procedure, you would write:
 
To use this instruction in a Visual Basic procedure, you would write:
  
<pre class="CODESAMP">  WordObj.ToolsMacro &quot;MacroName&quot;, True </pre>
+
<pre class="CODESAMP">  WordObj.ToolsMacro "MacroName", True </pre>
The &quot;True&quot; value is the Visual Basic equivalent to choosing/specifying the Run command button. You can use the &quot;False&quot; 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.<br />
+
The "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.<br />
 
<br />
 
<br />
The following Visual Basic procedure opens the Test macro for editing (the equivalent of ToolsMacro .Name = &quot;Test&quot;, .Edit).<br />
+
The following Visual Basic procedure opens the Test macro for editing (the equivalent of ToolsMacro .Name = "Test", .Edit).<br />
 
<br />
 
<br />
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; 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.
+
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.
  
 
<pre class="CODESAMP">Sub Command1_Click ()
 
<pre class="CODESAMP">Sub Command1_Click ()
 
Dim WordObj As Object
 
Dim WordObj As Object
Set WordObj = CreateObject(&quot;Word.Basic&quot;)
+
Set WordObj = CreateObject("Word.Basic")
WordObj.ToolsMacro &quot;Test&quot;, , True
+
WordObj.ToolsMacro "Test", , True
 
End Sub </pre>
 
End Sub </pre>
 
If you remove the comma before True, the instruction will run the Test macro. For example:
 
If you remove the comma before True, the instruction will run the Test macro. For example:
  
<pre class="CODESAMP">  WordObj.ToolsMacro &quot;Test&quot;, True </pre>
+
<pre class="CODESAMP">  WordObj.ToolsMacro "Test", True </pre>
 
Additional query words: 6.0 ole automation word basic word6 7.0 word95 word7 winword object position visual true
 
Additional query words: 6.0 ole automation word basic word6 7.0 word95 word7 winword object position visual true
  

Latest revision as of 08:49, 20 July 2020

OLE Automation: Specifying a Command Button from Visual Basic

Q105581



The information in this article applies to:


  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows, version 7.0





SUMMARY

Using 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", .Run 

To use this instruction in a Visual Basic procedure, you would write:

   WordObj.ToolsMacro "MacroName", True 

The "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 Sub 

If you remove the comma before True, the instruction will run the Test macro. For example:

   WordObj.ToolsMacro "Test", True 

Additional query words: 6.0 ole automation word basic word6 7.0 word95 word7 winword object position visual true

Keywords : kbole
Issue type :
Technology :


Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.