sdickens
asked on
Referencing data in a Drop down box
This should be easy, but I've been at it for a while and thought maybe someone could help. (Besides I'm an embedded guy!) I'm making a Word template for a friend and am a bit rusty in VB. The document has several statements that have a drop down box in them....ie
The car (was/was not) blue.
(was/ was not are the choices in the drop down). I want to have a macro that will make the entire statement bold if the second option (in this example 'was not') is selected. I don't need help with making it bold, what I need to know is how to reference the value in the drop-down box in VB. The code that I have is this:
************************** *****
Sub Bold1()
'
' Bold1 Macro
' Macro created 6/17/2002 by Shawn Dickens
'
Set vSel = ActiveDocument.FormFields( "DropDown1 ").
If (vSel = "were not") Then
Selection.EndKey Unit:=wdLine
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.Font.Underline = wdUnderlineSingle
End If
************************** *
If anyone could tell me what to set vSel equal to, I'd really apprecitate it...(Dropdown1 is what that the Bookmark is in the Drop-Down Field Options window in Word) I'm not sure if it even belongs there.
The car (was/was not) blue.
(was/ was not are the choices in the drop down). I want to have a macro that will make the entire statement bold if the second option (in this example 'was not') is selected. I don't need help with making it bold, what I need to know is how to reference the value in the drop-down box in VB. The code that I have is this:
**************************
Sub Bold1()
'
' Bold1 Macro
' Macro created 6/17/2002 by Shawn Dickens
'
Set vSel = ActiveDocument.FormFields(
If (vSel = "were not") Then
Selection.EndKey Unit:=wdLine
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.Font.Underline = wdUnderlineSingle
End If
**************************
If anyone could tell me what to set vSel equal to, I'd really apprecitate it...(Dropdown1 is what that the Bookmark is in the Drop-Down Field Options window in Word) I'm not sure if it even belongs there.
ASKER
Paul,
I tried that and got a compile error saying 'Object Required'
I tried that and got a compile error saying 'Object Required'
Interesting ... The result property is what you are looking for however.
How about:
vsel = ActiveDocument.FormFields( "DropDown1 ").DropDow n.ListEntr ies(Active Document.F ormFields( "DropDown1 ").DropDow n.Value).N ame
vsel = ActiveDocument.FormFields(
ASKER
Got the same error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got the same error
ASKER
Silly me...still had the set in there. Thanks a ton!
vSel = ActiveDocument.FormFields(