WD: Changing a Macro to Execute-Only Status

ID: Q79024

The information in this article applies to:

SUMMARY

Using the Microsoft WordBasic MacroCopy statement, an editable macro can be changed to an execute-only macro. After a macro is changed to execute-only status, you cannot open the macro for editing or viewing purposes. When a macro is changed to execute-only, the Edit button in the Macro dialog is unavailable (greyed) when the macro name is selected. The execute-only option was introduced in Word version 2.0 for Windows and is used to protect macros from being modified.

MORE INFORMATION

Prior to changing a macro to execute-only status, make a backup copy of the macro text in another file. After you change the status to execute-only, the macro is no longer editable.

The syntax for marking a macro as execute-only is as follows:

 MacroCopy [Template1:]Macro1$, [Template2:]Macro2$ [, ExecuteOnly]

 Template1, Template2:  The open template containing the macro you
                        want to copy and the open template to which
                        you want to copy the macro, respectively.

 Macro1$, Macro2$:      The name of the macro to copy and the name of
                        the new macro, respectively.

If you don't specify a source or destination template, the Normal template is assumed. The following macro instruction copies the FileNew macro from the TEMP.DOT file to FileNew in the NORMAL.DOT template file. The "ExecuteOnly" parameter is a value other that zero; therefore, the FileNew macro is given execute-only status in the NORMAL.DOT template file.

   MacroCopy "Temp.Dot:FileNew", "Global:FileNew", 1

NOTE: A macro cannot change itself to execute-only status. You must run the MacroCopy command from another macro to change a macro to execute-only status.

You cannot have the macro name listed in the MacroCopy command open for editing when you run the MacroCopy command. For example, when running the following macro

   MacroCopy "Global:FileMac", "Global:FileMac", 1

you cannot open the macro named "FileMac" in the macro editor.

After you change a macro to execute-only status, you cannot access the macro-editing window. The macro is not compiled or specially encrypted. Macro keywords are always compressed to three-byte tokens in order to save space, but literal strings (subroutine and function names and comments) are stored as text in the template file and are visible using a file reader.

For more information on the MacroCopy function, search for "WordBasic Programming Language" and "MacroCopy" using the Help menu.

For information about how to do this in Word 97, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q159748
   TITLE     : How to Protect VB Code from Unauthorized Access

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, pages 253-254

Additional query words: exe compile gray winword word6 word95 encrypt greyed grayed macword word7 winword winword2

Keywords          : kbmacro wordnt kbmacroexample winword ntword macword word6 word7 word95 
Version           : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.1a
Platform          : MACINTOSH Win95 WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: February 4, 1998