L
LEU
Below is a section of my macro. Is there a way to do a loop?
Dim i as Long
Dim WC35 As String, WC36 As String, WC37 As String
Set oFF = ActiveDocument.FormFields
If oFF("Check35").CheckBox.Value = False And Me.Controls("Ck35").Value =
False Then
WC35 = False
ElseIf oFF("Check35").CheckBox.Value = False And Me.Controls("Ck35").Value =
True Then
WC35 = False
ElseIf oFF("Check35").CheckBox.Value = True And Me.Controls("Ck35").Value =
False Then
WC35 = True
ElseIf oFF("Check35").CheckBox.Value = True And Me.Controls("Ck35").Value =
True Then
WC35 = False
End If
If oFF("Check36").CheckBox.Value = False And Me.Controls("Ck36").Value =
False Then
WC36 = False
ElseIf oFF("Check36").CheckBox.Value = False And Me.Controls("Ck36").Value =
True Then
WC36 = False
ElseIf oFF("Check36").CheckBox.Value = True And Me.Controls("Ck36").Value =
False Then
WC36 = True
ElseIf oFF("Check36").CheckBox.Value = True And Me.Controls("Ck36").Value =
True Then
WC36 = False
End If
If oFF("Check37").CheckBox.Value = False And Me.Controls("Ck37").Value =
False Then
WC37 = False
ElseIf oFF("Check37").CheckBox.Value = False And Me.Controls("Ck37").Value =
True Then
WC37 = False
ElseIf oFF("Check37").CheckBox.Value = True And Me.Controls("Ck37").Value =
False Then
WC37 = True
ElseIf oFF("Check37").CheckBox.Value = True And Me.Controls("Ck37").Value =
True Then
WC37 = False
End If
Set oFF = Nothing
I tried the following but the debugger kept giving me an error at ‘(“WC†&
i)’.
Set oFF = ActiveDocument.FormFields
For i = 35 To 37
If oFF("Check" & i).CheckBox.Value = False And Me.Controls("Ck" & i).Value =
False Then
(“WC†& i) = False
ElseIf oFF("Check" & i).CheckBox.Value = False And Me.Controls("Ck" &
i).Value = True Then
(“WC†& i) = False
ElseIf oFF("Check" & i).CheckBox.Value = True And Me.Controls("Ck" &
i).Value = False Then
(“WC†& i) = True
ElseIf oFF("Check" & i).CheckBox.Value = True And Me.Controls("Ck" &
i).Value = True Then
(“WC†& i) = False
End If
Next i
Set oFF = Nothing
Dim i as Long
Dim WC35 As String, WC36 As String, WC37 As String
Set oFF = ActiveDocument.FormFields
If oFF("Check35").CheckBox.Value = False And Me.Controls("Ck35").Value =
False Then
WC35 = False
ElseIf oFF("Check35").CheckBox.Value = False And Me.Controls("Ck35").Value =
True Then
WC35 = False
ElseIf oFF("Check35").CheckBox.Value = True And Me.Controls("Ck35").Value =
False Then
WC35 = True
ElseIf oFF("Check35").CheckBox.Value = True And Me.Controls("Ck35").Value =
True Then
WC35 = False
End If
If oFF("Check36").CheckBox.Value = False And Me.Controls("Ck36").Value =
False Then
WC36 = False
ElseIf oFF("Check36").CheckBox.Value = False And Me.Controls("Ck36").Value =
True Then
WC36 = False
ElseIf oFF("Check36").CheckBox.Value = True And Me.Controls("Ck36").Value =
False Then
WC36 = True
ElseIf oFF("Check36").CheckBox.Value = True And Me.Controls("Ck36").Value =
True Then
WC36 = False
End If
If oFF("Check37").CheckBox.Value = False And Me.Controls("Ck37").Value =
False Then
WC37 = False
ElseIf oFF("Check37").CheckBox.Value = False And Me.Controls("Ck37").Value =
True Then
WC37 = False
ElseIf oFF("Check37").CheckBox.Value = True And Me.Controls("Ck37").Value =
False Then
WC37 = True
ElseIf oFF("Check37").CheckBox.Value = True And Me.Controls("Ck37").Value =
True Then
WC37 = False
End If
Set oFF = Nothing
I tried the following but the debugger kept giving me an error at ‘(“WC†&
i)’.
Set oFF = ActiveDocument.FormFields
For i = 35 To 37
If oFF("Check" & i).CheckBox.Value = False And Me.Controls("Ck" & i).Value =
False Then
(“WC†& i) = False
ElseIf oFF("Check" & i).CheckBox.Value = False And Me.Controls("Ck" &
i).Value = True Then
(“WC†& i) = False
ElseIf oFF("Check" & i).CheckBox.Value = True And Me.Controls("Ck" &
i).Value = False Then
(“WC†& i) = True
ElseIf oFF("Check" & i).CheckBox.Value = True And Me.Controls("Ck" &
i).Value = True Then
(“WC†& i) = False
End If
Next i
Set oFF = Nothing