WD: Different Same-Name Macro Runs in Word 6.x than Word 2.x |
Q111688
The information in this article applies to:
- Microsoft Word for Windows, versions 6.0, 6.0a
- Microsoft Word for the Macintosh, versions 6.0, 6.0.1
SYMPTOMS
In Word 6.x, when you run a macro that you created in Word 2.x, errors may occur or Call statements may run a same-name macro from the wrong template.
CAUSE
Word 6.x follows a different set of rules than Word 2.x does to determine which template macro to run when two macros have the same name: Word 2.x runs the macro from the template attached to the document where the insertion point is currently located, and Word 6.x runs the macro from the template from which you launched the macro. This difference in resolving macro naming conflicts may cause errors when you run Word 2.x macros in Word 6.x.
STATUS
Microsoft has confirmed this to be a problem in the versions of Microsoft Word listed at the beginning of this article. This problem was corrected in later versions of Microsoft Word with the addition of a new WordBasic command, WW2CallingConvention(). In Word 6.0a and later, you can use WW2CallingConvention() to toggle between the Word 2.x and Word 6.x methods for resolving macro name conflicts. Refer to the "More Information" section below for details about WW2CallingConvention().
MORE INFORMATION
Microsoft 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please see the following page on the World Wide Web:
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
In both Word versions 2.x and 6.x, you can call one macro from another using the ToolsMacro statement or the following Call syntax:
[Call] MacroName[.SubName] [ArgumentList]
In Word 2.x, if there are two macros with the same name, Word runs the macro from the active template (that is, the template where the insertion point is located), whereas Word 6.x runs the macro from the template where the calling macro resides.
WW2CallingConvention Statement Syntax
WW2CallingConvention [0, 1]
The WW2CallingConvention statement toggles between the Word 6.x and Word 2.x naming-conflict resolution method.
Value Explanation ----- ----------- 0 Word 6.x behavior (in favor of the calling template) 1 Word 2.x behavior (in favor of the active template)
NOTE: The default argument is 1. In other words, if you do not include an argument, WW2CallingConvention switches to Word 2.x behavior.
WW2CallingConvention() Function Syntax
WW2CallingConvention()
Value Explanation ----- ----------- 0 Word 6.x Mode (Word 6.x calling convention is currently in effect) -1 Word 2.x Mode (Word 2.x calling convention is currently in effect)
Demonstration: Difference Between Word 2.x and Word 6.x Conventions
Use the following procedure to demonstrate the difference between the two WW2CallingConvention settings:
Create the following macro in Normal.dot named Test1:
Sub Main MsgBox "This is from Normal.dot" End Sub
Create the following macro in Template.dot named Test1:
Sub Main MsgBox "This is from Template.dot" End Sub
Create the following macro in Normal.dot named LikeWord2:
Sub Main WW2CallingConvention 1 FileNew .Template = "Template.dot" Call Test1 End Sub
Create the following macro in Normal.dot named LikeWord6:
Sub Main WW2CallingConvention 0 FileNew .Template = "Template.dot" Call Test1 End Sub
- Run the "LikeWord2" macro.
- Run the "LikeWord6" macro.
To obtain Word 6.0c, call the Microsoft Order Desk at (800) 360-7561 and request the Word 6.0c update. If you are outside the United States, contact the Microsoft subsidiary for your area. If you are outside the United States, contact your local subsidiary. To locate your subsidiary, see the Microsoft World Wide Offices Web site at:
Additional query words: hierarchy wrong precedence takes first second instead context ip custsales
Keywords : kbmacro wordnt kbmacroexample macword word6
Issue type : kbprb
Technology : kbWordSearch kbWordWSearch kbWordMSearch
Last Reviewed: December 29, 2000 |