Steps to write and activate macro in Word 2003

T

TNSanofi

Folks,

Any step by step for adding a macro into a word 2003 document?

I want to read one Bookmark A and based on this value show in another field
a default value for Bookmark B or text field. Example: The dropdown value
selected is equal to text "NYC", the default value sould be text "SOHO". How
do I get SoHo to show up in Bookmark B or text field? Then if the dropdown
value is changed to "Boise" the default value in the other field would be
default to "Idaho".

thx.
 
G

Greg Maxey

Assuming your have a dropdown field ("Dropdown1") and a text field
("Text1"), copy the following code to a project module in the
document:

Sub OnExitDD1()
Dim oFFs As FormFields
Set oFFs = ActiveDocument.FormFields
Select Case oFFs("Dropdown1").Result
Case "NYC"
oFFs("Text1").Result = "SOHO"
Case "Boise"
oFFs("Text1").Result = "Idaho"
Case Else
'Do Nothing
End Select
End Sub

Unprotect the form, double click the dropdown field and set
"OnExitDD1" to run on exit. Double click the text field and uncheck
"Enabled"

Reprotect and your done.
 

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