WD: Cannot Trap WordBasic Errors Greater Than 1000

Last reviewed: February 3, 1998
Article ID: Q124531
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

SYMPTOMS

You cannot suppress Word error messages using the WordBasic On Error, Err, and Error statements.

NOTE: Error messages that appear in Word for Windows can be classified in two groups: Word errors and WordBasic errors.

STATUS

This problem was corrected in Word 97 for Windows and Word 98 Macintosh Edition.

MORE INFORMATION

Error messages numbered 1001 and higher are Word error messages. An error message box appears when a Word error occurs, regardless of whether your macro contains error-trapping statements. For example:

   Sub MAIN
      On Error Goto errors
      FileOpen .Name = "fred.doc"
   errors:
      If err = 1078 Then Print "File does not exist"
   End Sub

The WordBasic On Error statement does not keep Word error message number 1078 from appearing. To avoid Word error messages, your macro must prevent the error situation from occurring. In the case of opening a file that doesn't exist, you could change the macro to check whether the file exists before it tries to open the file. For example:

   Sub MAIN
      a$ = Files$("FRED.DOC")
      If a$ <> "" Then FileOpen .Name = "fred.doc"
   End Sub

Note: The Files$ command will return a null string ("") if the specified file is not found.

REFERENCES

"Microsoft Word Developer's Kit," for version 6.0, pages 833-834

"Microsoft Word Developer's Kit," for version 6.0, Mac NT edition, page 849.


Additional query words: err on error
Keywords : kbmacroexample macword winword word7 word95 kbcode kberrmsg kbmacro
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Solution Type : kbfix


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.