WD98: How to Protect VBA Code from Unauthorized Access

Last reviewed: February 18, 1998
Article ID: Q181183
The information in this article applies to:
  • Microsoft Word 98 Macintosh Edition

SUMMARY

In earlier versions of Word, you can use the WordBasic MacroCopy statement to convert an editable macro to an execute-only macro. You cannot edit or view an execute-only macro.

The execute-only option is used with earlier versions of Word that use WordBasic as their programming language and is used to protect macros from being modified. This execute-only feature is no longer available in Word 98 and later versions. Instead, you can use the Microsoft Visual Basic for Applications Lock Project property to protect your code from unauthorized changes or to prevent others from viewing the code.

MORE INFORMATION

Follow these steps to lock your project:

  1. Start the Microsoft Visual Basic Editor and open your project.

  2. On the Tools menu, click Project Properties, and then click the General tab.

  3. Set the following properties:

        - Project Name
        - Project Description
        - Help File Name
        - Project Help Context ID
    

  4. Click the Protection tab.

  5. Click to select the Lock Project For Viewing check box.

  6. Type your password in the Password and Confirm Password boxes.

  7. Save and close your project.

    NOTE: Protection does not take effect until you save and close your project.

For more information about locking projects, click the Office Assistant while in the Visual Basic Editor,, type "lock project" (without the quotation marks), click Search, and then click to view "Protection Tab (Project Properties dialog Box)."

REFERENCES

For more information about how to change a macro to execute-only status in earlier versions of Word, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q79024
   TITLE     : WinWord: Changing a Macro to Execute-Only Status

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for 
               Applications


Additional query words: protect protecting protects execute only executable
vb vba vbe
Keywords : kbdta OffVBA macword98
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 18, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.