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

ID: 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 95, 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:

  1. Using the instructions on page 787 of the "Microsoft Word for Windows User's Guide," start the Dialog Editor.


  2. From the Item menu, choose Button. Create an OK button and a Cancel button.


  3. From the Item menu, choose List Box. Select Standard Box, then choose the OK button.


  4. From the File menu, choose Exit. Choose the Yes button when prompted to save changes to the Clipboard.


  5. 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, "Microsoft Word"
                OKButton 220, 6, 88, 21
                ListBox 45, 9, 160, 84, ListBox1$(), .ListBox1
                CancelButton 219, 31, 88, 21
             End Dialog
          End SUB 


  6. 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) = "Entry 1"
             ListBox1$(1) = "Entry 2"
             ListBox1$(2) = "Entry 3"
             ListBox1$(3) = "Entry 4"
             ListBox1$(4) = "Entry 5"
             ListBox1$(5) = "Entry 6"
             Begin Dialog UserDialog 320, 110, "Microsoft Word"
                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 


  7. 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.



REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, pages 787-792

"Using WordBasic," by WexTech Systems and Microsoft, pages 252-253

Additional query words: macrode.exe

Keywords : winword word6 winword2 word7 word95 kbFont macword6
Version : MACINTOSH:6.0,6.0.1; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbhowto


Last Reviewed: December 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.