How lock some fields in Word Form

  • Thread starter Patricio Hidalgo
  • Start date
P

Patricio Hidalgo

Hi,

I designed a form with some fields and when press a button to sign the
document I need locked these fields with information. Can I do that in word
with VBA?

Thanks a lot for the helpful
 
M

macropod

Hi Patricio,

You do this with code like:
Sub LockFmFlds()
Dim oFmFld As FormField
With ActiveDocument
For Each oFmFld In .FormFields
If oFmFld.Type = wdFieldFormTextInput Then oFmFld.Enabled = False
Next
End With
End Sub

The above code locks all text formfields. If you want to lock a specific formfield, you could usecode like:

Sub LockOneFld()
ActiveDocument.FormFields("Text1").Enabled = False
End Sub
where "Text1" is the bookmark name assigned to the formfield.
 
P

Patricio Hidalgo

Thanks macropod,

Sorry for the delay with the status, I was on vacaction.

Your solution is great, that's running well.

Patricio

macropod said:
Hi Patricio,

You do this with code like:
Sub LockFmFlds()
Dim oFmFld As FormField
With ActiveDocument
For Each oFmFld In .FormFields
If oFmFld.Type = wdFieldFormTextInput Then oFmFld.Enabled = False
Next
End With
End Sub

The above code locks all text formfields. If you want to lock a specific formfield, you could usecode like:

Sub LockOneFld()
ActiveDocument.FormFields("Text1").Enabled = False
End Sub
where "Text1" is the bookmark name assigned to the formfield.

--
Cheers
macropod
[MVP - Microsoft Word]


Patricio Hidalgo said:
Hi,

I designed a form with some fields and when press a button to sign the
document I need locked these fields with information. Can I do that in word
with VBA?

Thanks a lot for the helpful
 

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