How to Use a Combo Box with a Text Form Field

Last reviewed: August 4, 1997
Article ID: Q118482
6.00 6.00a WINDOWS kbusage kbmacro kbhowto

The information in this article applies to:

  • Microsoft Word for Windows, versions 6.0, 6.0a, and 6.0c
  • Microsoft Word for Macintosh, versions 6.0 and 6.0.1
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, version 7.0
  • Microsoft Windows operating system version 3.1

SUMMARY

This article describes how to create and use a combo box as an on-entry macro for a text form field. This macro can be used as a workaround for the 25-item limitation in drop-down form fields.

MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Create the following macro. To create the macro, from the Tools menu, choose Macro. Type "ComboBox" under Macro Name and choose the Create button. Type the following macro. (Make sure there is only one "Sub MAIN" and one "End Sub" in your macro.) Close and save the macro.

Sub MAIN
Dim Array$(3) Array$(0) = "This" Array$(1) = "is" Array$(2) = "a" Array$(3) = "test" Begin Dialog UserDialog 320, 144, "Microsoft Word"
     ComboBox 10, 6, 160, 108, Array$(), .Text
     OKButton 201, 8, 88, 21
     CancelButton 201, 35, 88, 21
End Dialog Dim dlg1 As UserDialog n = Dialog dlg1 Select Case n
     Case - 1
          Dim dlg2 As FormFieldOptions
          GetCurValues dlg2
          SetFormResult dlg2.Name, dlg1.Text
     Case Else
End Select
End Sub

In your form, add a text form field. To insert this field, choose Form Field from the Insert Menu, choose Text and choose the OK button. Double- click the text form field. In the Text Form Field Options dialog box, select the ComboBox macro from the list of macros under Run Macro On Entry. Choose the OK button. When the form is finished, choose Protect Document from the Tools menu. In the Protect Document dialog box, choose Forms and choose the OK button. When you tab to this form field, the combo box will display.

Kbcategory: kbusage kbmacro kbhowto KBSubcategory:


Additional reference words: 6.00 6.00a dropdown form text field macro word6
word7
word95 ntword wordnt macword combobox combo box winword drop down 25 limit
limits
limitations

Version : 6.00 6.00a
Platform : WINDOWS


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