Populating ActiveX Drop Down Menus in Word 2007

M

Maneesh

Can someone please help me with step-by-step instructions on how to populate
an ActiveX drop down menu in word 2007 and also to be able to make the user's
selection remain in the box when the document is closed and reopened, how can
we program Word 2007 drop downs to function as such.

Thanks a lot!
Please send answers to: (e-mail address removed)
 
D

Doug Robbins - Word MVP

Put the following in the ThisDocument item in the Microsoft Word Objects
folder for the document in the Visual Basic Editor

Private Sub ComboBox1_Change()
ActiveDocument.Variables("varComboBox1").Value = ComboBox1.Value
End Sub


Private Sub Document_Open()
Dim i As Long
For i = 1 To 10
ComboBox1.AddItem "Item" & i
Next i
On Error Resume Next
ComboBox1.Value = ActiveDocument.Variables("varComboBox1").Value

End Sub

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
M

Maneesh

Thanks Doug for the answer, but still my application is not working the way I
would like it to work.
The following lines of your code:

Dim i As Long
For i = 1 To 10
ComboBox1.AddItem "Item" & i
Next i
On Error Resume Next

puts "Item1, Item2, Item3 ...." in the combo-box instead of putting only 3
options that I want, namely: 'Choose One', 'Male' and 'Female'.

Besides this, I want the user's choice to be saved when the document is
closed and reopened. The given code is not behaving as such.
Please help me.
Thanks.
Maneesh Massey
Send answers to : (e-mail address removed)
 
D

Doug Robbins - Word MVP

Private Sub ComboBox1_Change()
ActiveDocument.Variables("varComboBox1").Value = ComboBox1.Value
End Sub

Private Sub Document_Open()
With ComboBox1
.AddItem "'Choose One"
.AddItem "Male"
.AddItem "Female"
End With

On Error Resume Next
ComboBox1.Value = ActiveDocument.Variables("varComboBox1").Value

End Sub


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top