Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Referencing data in a Drop down box

Posted on 2002-06-17
8
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

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!

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

660 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