Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Referencing data in a Drop down box

Posted on 2002-06-17
8
Medium Priority
?
219 Views
Last Modified: 2006-11-17
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
Comment
Question by:sdickens
  • 4
  • 4
8 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 7085000
Try:
vSel = ActiveDocument.FormFields("DropDown1").Result

0
 

Author Comment

by:sdickens
ID: 7088238
Paul,
I tried that and got a compile error saying 'Object Required'
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 7088423
Interesting ... The result property is what you are looking for however.
0
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.

 
LVL 38

Expert Comment

by:PaulHews
ID: 7088496
How about:

vsel = ActiveDocument.FormFields("DropDown1").DropDown.ListEntries(ActiveDocument.FormFields("DropDown1").DropDown.Value).Name
0
 

Author Comment

by:sdickens
ID: 7088643
Got the same error
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 800 total points
ID: 7088742
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
 

Author Comment

by:sdickens
ID: 7090535
Got the same error
0
 

Author Comment

by:sdickens
ID: 7090543
Silly me...still had the set in there.  Thanks a ton!
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question