Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Dropdown box to run macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Brown - 10 Sep 2005 10:18 GMT
Hello all,

I've created a form in Word 97 containing various drop down boxes. The drop
down boxes contain a yes or no selection and based on the selection I would
like to run a specific macro if yes is selected or a different macro if no
is selected. Can anyone help?

Many thanks.

Paul.
Doug Robbins - 10 Sep 2005 14:49 GMT
Run the macro named a on exit from the form field.  Depending upon the
selection b will run if it's "Yes"; c if it's "No"

Sub a()
Dim mydrop
Set mydrop = ActiveDocument.FormFields("Dropdown1")
If mydrop.DropDown.ListEntries(mydrop.DropDown.Value).Name = "Yes" Then
   Call b
Else
   Call c
End If
End Sub

Sub b()
MsgBox "User selected Yes"
End Sub

Sub c()
MsgBox "User selected No"
End Sub

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello all,
>
[quoted text clipped - 6 lines]
>
> Paul.
Paul Brown - 10 Sep 2005 16:53 GMT
Many thanks. Works a treat.

> Run the macro named a on exit from the form field.  Depending upon the
> selection b will run if it's "Yes"; c if it's "No"
[quoted text clipped - 27 lines]
>>
>> Paul.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.