Dropdown box to run macro

P

Paul Brown

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.
 
D

Doug Robbins

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



--
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
 
P

Paul Brown

Many thanks. Works a treat.

Doug Robbins said:
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



--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top