WordBasic Error with Dialog Box Created in Macro Dialog Editor

Last reviewed: July 30, 1997
Article ID: Q88423
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, version 7.0

SUMMARY

When you use the Dialog Editor to create an option button, if you type text in the Text$ box and select the Auto Quote check box, a WordBasic error may appear when you run the resulting macro in Microsoft Word for Windows. The error message occurs if you type quotation marks in the Text$ field of the Button Info dialog box in Dialog Editor. No error message occurs if you do not type quotation marks in the Text$ field.

The error message occurs because the Dialog Editor does not translate literal quotation marks to "Chr$(34)" in the Text$ box.

MORE INFORMATION

The Dialog Editor is used to create custom dialog boxes for use with Word for Windows WordBasic macros. The Auto Quote option automatically encloses button label text in quotation marks so that you don't have to type the quotation marks yourself. In effect, the Auto Quote option forces the text you type to be a string variable, rather than a literal.

Workaround

If you want quotation marks to appear around text in a macro, you must use the Chr$(34) statement instead of literal quotation marks. When the Auto Quote check box is selected, do not type any quotation marks in the Text$ field of the Button Info dialog box. If you want to add quotation marks, add them after you paste the text in the macro-editing window in Word for Windows.

For example, to add an option button title such as ""My" Button" while the Auto Quote check box is selected, type "My Button" in the Text$ box (without the quotation marks). When you paste the dialog box in the Word for Windows macro-editing window, the following text appears:

   OptionButton 10, 6, 110, 16, "My Button"

Modify the line so that it reads as follows:

   OptionButton 119, 107, 121, 16, Chr$(34) + "My" + Chr$(34) +
   " Button"

Steps to Reproduce Problem

  1. Launch the Dialog Editor. For information on this procedure, refer to pages 787-790 of the "Microsoft Word for Windows User's Guide."

  2. From the Item menu in the Dialog Editor, choose Button. Under Button Type, select Option, then choose the OK button.

  3. Double-click the option button to open the Option Button Info dialog box. In the Text$ box, type the following:

          "My" Button
    

  4. Select the Auto Quote check box, then choose the OK button. Notice that the quotation marks display correctly in the dialog box.

  5. From the Edit menu, choose Select Dialog. From the Edit menu, choose Copy. From the File menu, choose Exit to close the Dialog Editor.

  6. Launch Word for Windows. From the Tools menu, choose Macro. Type a macro name, such as "TestDialog" (without the quotation marks), and choose the Edit button.

  7. From the Edit menu, choose Paste. The following text should now appear in the macro-editing window:

          Sub MAIN
          Begin Dialog UserDialog 320, 144, "Microsoft Word"
             OptionGroup  .OptionGroup1
                OptionButton 10, 6, 110, 16, ""My" Button"
          End Dialog
          End Sub
    
    

  8. Type the following lines before the "End Sub" line and after the "End Dialog" line in the above macro:

          Dim dlg as UserDialog
          Dialog dlg
    

  9. Choose the Start button on the macro-editing bar to run the macro.

The above steps produce the following error message:

   WordBASIC Err=100
   Syntax Error

REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, pages 787-788, 790-791

"Using WordBasic," by WexTech Systems and Microsoft, page 163

Kbcategory: kbusage kbmacro KBSubcategory:


Additional query words: winword2 2.0 2.0a 2.0a-CD winword 6.0c
winword 7.0 word95 word7 word6 winword macrode.exe errmsg err msg double
winword2 6.0
Version : 2.x 6.0 6.0a 6.0c 7.0
Platform : WINDOWS


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