WordBasic Error with Dialog Box Created in Macro Dialog Editor
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. 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
- Launch the Dialog Editor. For information on this procedure, refer
to pages 787-790 of the "Microsoft Word for Windows User's Guide."
- 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:
"My" 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:
Sub MAIN
Begin Dialog UserDialog 320, 144, "Microsoft Word"
OptionGroup .OptionGroup1
OptionButton 10, 6, 110, 16, ""My" Button"
End Dialog
End Sub
- 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
- 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
Additional query words:
winword2 2.0 winword 7.0 word95 word7 word6 macrode.exe errmsg err msg double 6.0
Keywords :
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0
Platform : WINDOWS
Issue type :
|