Solved

Word RowSource syntax

Posted on 2014-07-24
4
1,514 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

688 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