PDA

View Full Version : Solved: Form Fields



gibbo1715
11-08-2005, 07:47 AM
Can anyone tell me the correct syntax for the code below please

Im trying just to set the enabled property to false only in section(1)

Cheers

Gibbo

Private Sub CommandButton1_Click()
For Each aField In ActiveDocument.Sections(1).FormFields
If aField.Type = wdFieldFormTextInput Then
aField.Enabled = False
End If
Next aField
End Sub

gibbo1715
11-08-2005, 08:21 AM
I ve used a different approach that does work for me but im not really happy with it and would prefer to lock my form parts based on sections

Cheers

Gibbo

i = 1
For Each aField In ActiveDocument.FormFields
If aField.Type = wdFieldFormTextInput And i < 6 Then
aField.Enabled = False
i = i + 1
' Else
' aField.Enabled = True
End If
Next aField

fumei
11-08-2005, 10:04 AM
You need to use the .Range of the Section. Try this.
Sub CommandButton1_Click()
Dim aField As Word.FormField
For Each aField In ActiveDocument.Sections(1).Range.FormFields()
aField.Enabled = False
Next
End Sub

gibbo1715
11-08-2005, 10:41 AM
Thanks, just the job

Gibbo