Solved

Referencing data in a Drop down box

Posted on 2002-06-17
8
212 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
Comment Utility
Try:
vSel = ActiveDocument.FormFields("DropDown1").Result

0
 

Author Comment

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

Expert Comment

by:PaulHews
Comment Utility
Interesting ... The result property is what you are looking for however.
0
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
How about:

vsel = ActiveDocument.FormFields("DropDown1").DropDown.ListEntries(ActiveDocument.FormFields("DropDown1").DropDown.Value).Name
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sdickens
Comment Utility
Got the same error
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 200 total points
Comment Utility
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
Comment Utility
Got the same error
0
 

Author Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now