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

Last reviewed: February 2, 1998
Article 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
  • 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 : kbfont winword winword2 word6 word7 word95 word97 macword6
Version : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a;MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


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