Solved

Word RowSource syntax

Posted on 2014-07-24
4
1,314 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
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now