WD: FileClose in Macro Doesn't Work with Protected Form

ID: Q126366

The information in this article applies to:

SYMPTOMS

If a WordBasic macro contains FileClose and the macro is used on exit from a form field of a protected document, the FileClose command will not function, and the following error message will appear:

   WordBasic Err=102, Command Failed

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.

Use the following macro instead of the FileClose command in a macro to close a protected form:

   Sub MAIN
      a = Now()
      OnTime a, "FileClose"
   End Sub

When using the above workaround, you will be unable to use the SAVE parameter for the FileClose command. If you need to use this parameter, use the SetDocumentDirty command instead. The following macro uses the SetDocumentDirty command to close the document without saving.

   Sub MAIN
      a = Now()
      SetDocumentDirty 0
      OnTime a, "FileClose"
   End Sub

STATUS

Microsoft has confirmed this to be a problem in Word versions 6.0, 6.0a, 6.0c, and 7.x. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Additional query words: forms

Keywords          : kberrmsg kbmacro wordnt winword ntword macword word6 word7 word95 
Version           : 6.0 6.0a 6.0c 7.0 7.0a | 6
Platform          : MACINTOSH WINDOWS
Issue type        : kbbug

Last Reviewed: February 6, 1998