Solved

Referencing data in a Drop down box

Posted on 2002-06-17
8
213 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
 
LVL 38

Expert Comment

by:PaulHews
ID: 7088496
How about:

vsel = ActiveDocument.FormFields("DropDown1").DropDown.ListEntries(ActiveDocument.FormFields("DropDown1").DropDown.Value).Name
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

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

Accepted Solution

by:
PaulHews earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now