The information in this article applies to:
SUMMARYIn Microsoft Word, when you choose the Cancel button in a custom dialog box, you receive the following error message: To Word, the Cancel button indicates a run-time error; therefore, Word halts execution of the macro. You can trap this error with an On Error command in your macro if you want to suppress the message and let the macro continue. An alternative method of trapping this error is to call the function form of the dialog box. When you choose the Cancel button, a value of 0 (zero) is returned instead of a WordBasic error. MORE INFORMATIONAn error trap statement within a sample section of macro code resembles the following example:
where "ExitMacroDialog" is a label somewhere beyond the dialog
statement for the dialog box.
The lines that include an apostrophe indicate there may be more macro code between the given statements. If you receive the WordBasic error 102 after putting the error trap into the macro, check to make sure the label is valid and that the On Error statement appears in order before the Dialog statement. Alternative Error Trapping Method 1:The alternative method for trapping the Cancel button in a custom dialog box is to call the function form of a dialog box. If you trap an error with this method, the "On Error Goto" statement is not used. The following is a sample macro that creates a custom dialog box using the function form of the dialog box. This method returns a value of 0 (zero) if you choose the Cancel button instead of halting the macro and generating the WordBasic error 102.
Alternative Error Trapping Method 2:This method also avoids the use of the "On Error Goto" statement. The "If" statement will run only if the OK button is clicked.
REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, pages 158, 173-174 Additional query words: winword2 6.0 1.x 2.0 word6 6.0.1 word7 winword 7.0 word95 macword
Keywords : winword word6 winword2 word7 word95 |
Last Reviewed: December 22, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |