Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

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.
0
sdickens
Asked:
sdickens
  • 4
  • 4
1 Solution
 
PaulHewsCommented:
Try:
vSel = ActiveDocument.FormFields("DropDown1").Result

0
 
sdickensAuthor Commented:
Paul,
I tried that and got a compile error saying 'Object Required'
0
 
PaulHewsCommented:
Interesting ... The result property is what you are looking for however.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PaulHewsCommented:
How about:

vsel = ActiveDocument.FormFields("DropDown1").DropDown.ListEntries(ActiveDocument.FormFields("DropDown1").DropDown.Value).Name
0
 
sdickensAuthor Commented:
Got the same error
0
 
PaulHewsCommented:
Are you still using "Set" in your statement?  Run it the way I printed it (use the first one, because I tested it and it works as expected.)
0
 
sdickensAuthor Commented:
Got the same error
0
 
sdickensAuthor Commented:
Silly me...still had the set in there.  Thanks a ton!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now