The information in this article applies to:
SYMPTOMS
When you run a Visual Basic For Applications macro containing the
"Application.Run Macroname:=" command in Microsoft Word or in another
Office program to automate Word, the following error
message may appear:
CAUSEYou have included a template name as part of the Macroname argument string. WORKAROUNDTo avoid naming conflicts among referenced projects, give your procedures unique names, so that you can call a procedure without specifying a project or module. RESOLUTIONRemove the template name from the Macroname argument. STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft support professionals 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
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/refguide/ In the online help, the Run method states that you can use the template name in the Macroname argument string, and then it shows the following examples as valid statements:
Visual Basic for Applications assigns names to macros in the following order:
When Visual Basic for Applications accesses the Microsoft Word Object model, a project can be either a template or document with stored procedures. In Visual Basic for Applications, the Word projects are named in the following manner:
The following illustration describes how Visual Basic for Applications handles Microsoft Word macros of the same name or macros and modules of the same name in different template and document projects that are active. In Microsoft Word, if you open a document named MyDoc.doc that is based on the template MyTemp.dot, both documents have a module called "Newmacros" and a macro called "MyMacro." At Startup, a template called "MyStart.dot" loads with the "Normal.dot" global template. Both of these templates have a module called "Newmacros", and there is a macro called "MyMacro" in the module. With the three templates and one document active in Microsoft Word, when the Macro dialog box appears, you see the following lines of code:
Open the Visual Basic Editor by pressing ALT+F11. Then, press CTRL+R to view the following in Project Explorer: Normal(Normal) Project(MyTemp) Project(MyDoc) TemplateProject(MyStart) If you want to run the macro in MyStart.dot, write your code as follows:
- or -
Additional query words: vb
Keywords : kbdta OffVBA kbmacroexample kbwordvba wd2000 |
Last Reviewed: May 13, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |