Microsoft KB Archive/79024

{|
 * width="100%"|

WD: Changing a Macro to Execute-Only Status

 * }

Q79024

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows 95, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

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 &quot;ExecuteOnly&quot; parameter is a value other that zero; therefore, the FileNew macro is given execute-only status in the NORMAL.DOT template file.

  MacroCopy &quot;Temp.Dot:FileNew&quot;, &quot;Global:FileNew&quot;, 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 &quot;Global:FileMac&quot;, &quot;Global:FileMac&quot;, 1 you cannot open the macro named &quot;FileMac&quot; 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 &quot;WordBasic Programming Language&quot; and &quot;MacroCopy&quot; using the Help menu.

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

"Q159748 How to Protect VB Code from Unauthorized Access"