Macro for Word Form to Disable Fill-In

J

JLewis

I'm looking for a macro to insert into a form I am designing in Word 2003. I
need a macro that will disable fill-in on specific fields only, by using the
last character of their bookmark names. Basically, I'm desiging a form that
one person fills in some of the fields, then another fills in the rest. I
don't want the 2nd person to be able to change what the 1st person filled in,
and I don't want to have to change each field's properties manually every
time.
 
J

Jay Freedman

JLewis said:
I'm looking for a macro to insert into a form I am designing in Word
2003. I need a macro that will disable fill-in on specific fields
only, by using the last character of their bookmark names.
Basically, I'm desiging a form that one person fills in some of the
fields, then another fills in the rest. I don't want the 2nd person
to be able to change what the 1st person filled in, and I don't want
to have to change each field's properties manually every time.

You didn't say exactly what value of the "last character of their bookmark
names" should cause the field to be disabled, but you can modify this code
to change the "1" to whatever you need.

Sub DisableFields()
' disable every field whose
' name ends with "1"
Dim oFF As FormField

For Each oFF In ActiveDocument.FormFields
If Right(oFF.Name, 1) = "1" Then
oFF.Enabled = False
End If
Next
End Sub

If the last character you're checking for is a letter, you should make the
condition case-insensitive like this:

If LCase(Right(oFF.Name, 1)) = "a" Then


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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