Microsoft KB Archive/87837

{|
 * width="100%"|

WD: How to Create a WordBasic List Box Using Dialog Editor

 * }

Q87837

-

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 NT, version 6.0
 * Microsoft Word for Windows, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SUMMARY
You can use the Microsoft Word Dialog Editor to create a list box for use in a WordBasic macro.

The WordBasic ListBox function displays an array list. From that list, you can choose one element to use in the macro.

MORE INFORMATION
To create a list box using the Dialog Editor, use the following steps:

 Using the instructions on page 787 of the &quot;Microsoft Word for Windows User's Guide,&quot; start the Dialog Editor. From the Item menu, choose Button. Create an OK button and a Cancel button. From the Item menu, choose List Box. Select Standard Box, then choose the OK button. From the File menu, choose Exit. Choose the Yes button when prompted to save changes to the Clipboard.  Launch Word. Open a new macro-editing window. Position the insertion point between the Sub Main and End SUB lines. From the Edit menu, choose Paste. The text in the macro-editing window should be similar to the following:      Sub Main Begin Dialog UserDialog 320, 110, &quot;Microsoft Word&quot; OKButton 220, 6, 88, 21 ListBox 45, 9, 160, 84, ListBox1$, .ListBox1 CancelButton 219, 31, 88, 21 End Dialog End SUB   Type the following text in the macro-editing window. (Note: The text pasted in step 4 above is included in the syntax below.)      Sub MAIN Dim ListBox1$(5) ListBox1$(0) = &quot;Entry 1&quot; ListBox1$(1) = &quot;Entry 2&quot; ListBox1$(2) = &quot;Entry 3&quot; ListBox1$(3) = &quot;Entry 4&quot; ListBox1$(4) = &quot;Entry 5&quot; ListBox1$(5) = &quot;Entry 6&quot; Begin Dialog UserDialog 320, 110, &quot;Microsoft Word&quot; OKButton 220, 6, 88, 21 ListBox 45, 9, 160, 84, ListBox1$, .ListBox1 CancelButton 219, 31, 88, 21 End Dialog Dim dlg As Dialog UserDialog Dialog dlg Insert ListBox1$(dlg.Listbox1) InsertPara End Sub  When you run this macro, the list box appears. Select one of the list box entries and choose the OK button. Word for Windows inserts the selection in the active document.</li></ol>