WD6x: Error: "ToolsProtectDocument Command Is Not Available"

Last reviewed: February 3, 1998
Article ID: Q120350
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1

SYMPTOMS

The following WordBasic error message may occur when you run a macro that protects a document for forms:

   The ToolsProtectDocument command is not available because the
   document is already protected.

CAUSE

You recorded the macro that protects your document. When you record the Protect Document command, Word for the Macintosh creates a macro that contains two ToolsProtectDocument statements. When the second instance of the statement is run, the above error occurs because the document is already protected.

In addition, if you continue to record TAB or ENTER keystrokes to move between form fields after you protect the document, Word places an "Unrecognized_Statement336" statement in the macro in place of each keystroke. For example, Word creates the following macro when you turn on the macro recorder, protect the document, press TAB or ENTER three times to move between form fields, and then unprotect the document:

   Sub MAIN
      ToolsProtectDocument .DocumentPassword = "", .NoReset = 0, .Type = 2
      ToolsProtectDocument .DocumentPassword = "", .NoReset = 0, .Type = 2
      Unrecognized_Statement336
      Unrecognized_Statement336
      Unrecognized_Statement336
      ToolsUnprotectDocument
   End Sub

NOTE: This problem does not occur in Word for Windows because Word for Windows stops the macro recorder automatically whenever you record the ToolsProtectDocument statement.

WORKAROUND

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Edit the macro to remove the duplicate ToolsProtectDocument command and replace the "Unrecognized_Statement336" statements with the appropriate WordBasic statements. For example, modify the macro to resemble the following:

   Sub MAIN
      ToolsProtectDocument .DocumentPassword = "", .NoReset = 0, .Type = 2
      Insert Chr$(9)
      Insert Chr$(9)
      Insert Chr$(9)
      ToolsUnprotectDocument
   End Sub

REFERENCES

"Microsoft Word User's Guide," version 6.0 (Macintosh), page 783


Additional query words: word basic
Keywords : kbmacroexample macword kberrmsg kbmacro
Version : MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH
Issue type : kbprb
Solution Type : kbworkaround


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 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.