Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access value of combobox ?

2 views
Skip to first unread message

Piotr Chmielewski

unread,
Feb 9, 2008, 5:05:07 PM2/9/08
to
Hi

I'm trying to write an VBA macro that opens some word document and
reads data from it. Unfortunately, I cannot find any info how to access
value of combo box in that document. Any idea how to do that?
(assuming that I have word.application object created and document
already opened)

Regards
Piotr


Tony Strazzeri

unread,
Feb 15, 2008, 10:35:47 PM2/15/08
to


It depends on what sort of combobox it is.

If it is a combobox inserted from the "Forms" toolbar then it will
have a default bookmark name. eg the first combobox will be caled
"DropDown1". You can of course change this.

To access the selected item for this use;
X = ActiveDocument.FormFields("DropDown1").Result

If the combobox is inserted from the "Control Toolbox" toolbar then
you need to write code in the control's event procedures. eg

Private Sub ComboBox1_LostFocus()
MsgBox "current val=" & ComboBox1.Text
End Sub

Hope this helps.


Cheers
TonyS.

0 new messages