Answered by:
Manipulating drop down lists in Word 2010

Question
-
Hi all,
I am being tasked with creating a form for our organization. While I've developed various forms using InfoPath and Adobe LifeCycle, due to the format of this document it has to be done in Word. The form is intended to be printed and has to adhere to a specific format that's already a word document. With that said, I am looking to do the following (all which are very easy to do in InfoPath or LiveCycle)
1. Add a drop down list that that contains various items, let's say user names for example. We'll call the drop down list UserName
2. When a user chooses a user name from the UserName drop down list, it should automatically populate within the form any field that calls for the "user name" with the value chosen from the drop down list. Let's say for example I have chosen the name "Bob" from the drop down list. I want the name "Bob" to appear automatically as required within the document. I would assume the fields would have to be linked some how, and this is where I am at a loss... I've tried bookmarks, or cross references, but nothing works.
3. I would like the drop down list to grab its item values from an existing Access Database. For example, instead of manually adding list items to the drop box, I would like to have those values pulled from an Access 2010 database. This will be strictly for pulling data, no need to for the Word form to update the Access database.
4. One nice thing I was able to do in Infopath is have a drop down list grab it's values from other data within the form. For example, let's say I had created a table with a row called "Serial Numbers", a user would manually input serial numbers into the table. Later within the document, I could create a drop down list that would grab it's values from the "Serial Number" row, i.e., the values of the drop down list would be every serial number that had been entered in a previous table. is there anyway to accomplish this within InfoPath?
Thanks in advanced for everything! I am a bit rusty in VB but can fumble my way through it if scripting/programming is required to accomplish this.
Thursday, April 18, 2013 1:38 AM
Answers
-
For Q1 & Q2:
1. Create a new Macro-Enabled Template (.dotm);
2. Insert a Combo Box (ActiveX control) from Developer --> Controls --> Legacy Forms --> Combo Box (ActiveX Control);
3. Insert 2 Textbox (ActiveX Control) from Developer --> Controls --> Legacy Forms --> Textbox (ActiveX Control);
(This textbox is used to display the named that changed with the dropdown list)
4. Press Alt+F11, copy and paste the following code sample to ThisDocument:
Option Explicit Const OPA = "Name A" Const OPB = "Name B" Const OPC = "Name C" Private Sub Document_Open() ComboBox1.List = Array(OPA, OPB, OPC) End Sub Private Sub ComboBox1_Change() Dim strCombox As String On Error Resume Next strCombox = ComboBox1.Value On Error GoTo 0 TextBox1.Text = strCombox TextBox2.Text = strCombox lbl_Exit: Exit Sub End Sub
8. Save and close the document, and open it again.
Max Meng
TechNet Community Support- Marked as answer by Max Meng Tuesday, April 30, 2013 3:08 AM
Monday, April 22, 2013 9:55 AM -
For Q3 & Q4, please check the following support article:
http://support.microsoft.com/kb/211190
Max Meng
TechNet Community SupportMonday, April 22, 2013 9:57 AM -
See: http://gregmaxey.mvps.org/word_tip_pages/repeating_data.html
Cheers
Paul Edstein
[MS MVP - Word]- Marked as answer by Max Meng Tuesday, April 30, 2013 3:08 AM
Monday, April 22, 2013 10:22 AM
All replies
-
For Q1 & Q2:
1. Create a new Macro-Enabled Template (.dotm);
2. Insert a Combo Box (ActiveX control) from Developer --> Controls --> Legacy Forms --> Combo Box (ActiveX Control);
3. Insert 2 Textbox (ActiveX Control) from Developer --> Controls --> Legacy Forms --> Textbox (ActiveX Control);
(This textbox is used to display the named that changed with the dropdown list)
4. Press Alt+F11, copy and paste the following code sample to ThisDocument:
Option Explicit Const OPA = "Name A" Const OPB = "Name B" Const OPC = "Name C" Private Sub Document_Open() ComboBox1.List = Array(OPA, OPB, OPC) End Sub Private Sub ComboBox1_Change() Dim strCombox As String On Error Resume Next strCombox = ComboBox1.Value On Error GoTo 0 TextBox1.Text = strCombox TextBox2.Text = strCombox lbl_Exit: Exit Sub End Sub
8. Save and close the document, and open it again.
Max Meng
TechNet Community Support- Marked as answer by Max Meng Tuesday, April 30, 2013 3:08 AM
Monday, April 22, 2013 9:55 AM -
For Q3 & Q4, please check the following support article:
http://support.microsoft.com/kb/211190
Max Meng
TechNet Community SupportMonday, April 22, 2013 9:57 AM -
See: http://gregmaxey.mvps.org/word_tip_pages/repeating_data.html
Cheers
Paul Edstein
[MS MVP - Word]- Marked as answer by Max Meng Tuesday, April 30, 2013 3:08 AM
Monday, April 22, 2013 10:22 AM