WD97: CALL Statement Cannot Accept Variable Argument (184627)
The information in this article applies to:
- Microsoft Word 98 Macintosh Edition
This article was previously published under Q184627 SYMPTOMS
In Microsoft Word, you can use the Microsoft Visual Basic for Applications
CALL statement to run another subroutine; however, you cannot specify the
name of the subroutine by using a string variable or concatenated strings.
Attempting to do so may result in the following error:
Compile Error: Syntax error
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
If the variable strMacroName contains the name of the macro, use this
statement:
Application.Run strMacroName
Or, if you are using literal strings:
Application.Run "Normal.Module1.MAIN"
Application.Run "MyProject.MyModule.MyProcedure"
Application.Run "'My Document.doc'!ThisModule.ThisProcedure"
If you specify the document or template name, your code can run macros only
in documents or templates related to the current context; it cannot run any
macro in any document or template.
Although Visual Basic code can call a macro directly (without using this
method), this method is useful when the macro name is stored in a
variable. The following two statements are functionally equivalent:
<ProjectName>.<ModuleName>.<MacroName>
Application.Run MacroName:="<ProjectName>.<ModuleName>.<MacroName>"
In cases where you call a literal string such as "AutoExec.Main", you
must remove the quotation marks, as shown in the following example:
CALL AutoExec.Main
NOTE: You cannot pass parameters to a macro by using the Run method.
REFERENCES
For more information about getting help with Visual Basic for Applications,
please see the following article in the Microsoft Knowledge Base:
163435 VBA: Programming Resources for Visual Basic for Applications
For more information about the Call statement, please see the following
articles in the Microsoft Knowledge Base:
164058 Passing Procedure Arguments in Visual Basic for Applications
165518 Calling Macros Using OLE from MS Visual Basic for Applications
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
Modification Type: | Major | Last Reviewed: | 9/1/2006 |
---|
Keywords: | kbdtacode kbnofix kbprb KB184627 |
---|
|