Microsoft KB Archive/88423

{|
 * width="100%"|

WordBasic Error with Dialog Box Created in Macro Dialog Editor

 * }

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, 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 &quot;Chr$(34)&quot; 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 &quot;&quot;My&quot; Button&quot; while the Auto Quote check box is selected, type My Button in the Text$ box. When you paste the dialog box in the Word for Windows macro-editing window, the following text appears:

  OptionButton 10, 6, 110, 16, &quot;My Button&quot; Modify the line so that it reads as follows:

  OptionButton 119, 107, 121, 16, Chr$(34) + &quot;My&quot; + Chr$(34) + &quot; Button&quot;

Steps to Reproduce Problem
 Launch the Dialog Editor. For information on this procedure, refer to pages 787-790 of the &quot;Microsoft Word for Windows User's Guide.&quot; From the Item menu in the Dialog Editor, choose Button. Under Button Type, select Option, then choose the OK button.  Double-click the option button to open the Option Button Info dialog box. In the Text$ box, type the following: "&quot;My&quot; Button" Select the Auto Quote check box, then choose the OK button. Notice that the quotation marks display correctly in the dialog box. From the Edit menu, choose Select Dialog. From the Edit menu, choose Copy. From the File menu, choose Exit to close the Dialog Editor. Launch Word for Windows. From the Tools menu, choose Macro. Type a macro name, such as TestDialog, and choose the Edit button.  From the Edit menu, choose Paste. The following text should now appear in the macro-editing window: <pre class="CODESAMP">     Sub MAIN Begin Dialog UserDialog 320, 144, &quot;Microsoft Word&quot; OptionGroup .OptionGroup1 OptionButton 10, 6, 110, 16, &quot;&quot;My&quot; Button&quot; End Dialog End Sub </li>  Type the following lines before the &quot;End Sub&quot; line and after the &quot;End Dialog&quot; line in the above macro: <pre class="CODESAMP">     Dim dlg as UserDialog Dialog dlg </li> Choose the Start button on the macro-editing bar to run the macro.</li></ol>

The above steps produce the following error message:

WordBASIC Err=100

Syntax Error