Solved

Word RowSource syntax

Posted on 2014-07-24
4
1,480 Views
Last Modified: 2014-07-25
This should be straight forward, but haven't been able to figure it out.  I have created a Word template that has a form that allows the user to make entries to populate the template.

There are free form text boxes and radio buttons.  I would like to add a simple list box offering a choice between several states.

I cannot for the life of me figure out the RowSource syntax.  I would think it would be something simple like ="Choice1, Choice2, Choice3,...." but this is not working.

I am going to use the value selected in the list box to insert a block of text that will vary depending on the selection.  I have done this successfully based on radio button choices and would like to do the same now with a listbox.
0
Comment
Question by:reportingdude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40217483
I'm not sure that Word supports bound controls. However, to be clear, are you using ActiveX controls? If so, are they on the document (not recommended), or on a UserForm?
0
 

Author Comment

by:reportingdude
ID: 40217562
Its a UserForm through VBA. I am not sure if the controls are ActiveX controls.  When I hit the toolbar button it has option button, list box, combo box, etc available.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40218702
The controls on a UserForm are all ActiveX controls. They can also be put on documents, but it isn't recommended.

I have researched this a bit more. As far as I can establish, the RowSource property only works if the data is on a Worksheet in the current Workbook. This confines it to Excel.

This Microsoft article http://support.microsoft.com/kb/161598 is headed "How to add data to a ComboBox control or a ListBox control in Excel or Word". The first uses the RowSource and shows how to set it to a worksheet range. The second method uses VBA to set the list to an array, which would, of course work in Word, or any other UserForm host.

A third method is to use AddItem successively
ListBox1.AddItem "Choice1"
ListBox1.AddItem "Choice2"

Open in new window

0
 

Author Closing Comment

by:reportingdude
ID: 40220158
Excellent.  Not sure how I missed finding that link, here are the directions from the link you provided that did the trick:

Methdod 2: How to Use a Visual Basic Macro to Populate a Combo Box or List Box
1.Open a Microsoft Office Application such as Microsoft Excel or Word.
2.Press ALT+F11 to start the Visual Basic Editor.
3.On the Insert menu, click UserForm.
4.Create a ComboBox and a ListBox control on the user form.
5.Right-click the user form and click View Code. The Code window for the user form appears. Click Initialize in the Procedure list (on the right side).

The first and last lines of the subroutine are automatically entered, and the insertion point is automatically placed between these two lines.
6.Type the following code:
      ListBox1.List = Array("One", "Two", "Three", "Four")
      ComboBox1.List = Array("Red", "Green", "Yellow", "Blue")
                                    This code should appear between the lines "Sub UserForm_Initialize()" and "End Sub".
7.On the Run menu, click Run Sub/UserForm to run the user form.
One, Two, Three, and Four appear in the ListBox control; and Red, Green, Yellow, and Blue appear in the ComboBox control.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question