D
Dylan
I have a calendar that inputs the selected date into a formfield in a table.
I want to add another field outside of the table and amend the VBA to apply
the date.
How do I make VBA recognise whether the formfield is in a table or just in
the body of the document? I tried - If rng.Tables(1).Columns.Count > 1
Then... but it doesn't work. I'm not an expert as you can see.
Dim rng As Range
Set rng = Selection.Range
On Error Resume Next
'Unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
If rng.Tables(1).Columns.Count > 1 Then
With rng.Cells(1)
.Range.FormFields(1).Result = Format(ctrlCal.Value, "dd MMM yyyy")
End With
Else: ActiveDocument.FormFields("pfield1").Result = Format(ctrlCal.Value,
"dd MMM yyyy")
End If
Unload Me...
regards
Dylan
I want to add another field outside of the table and amend the VBA to apply
the date.
How do I make VBA recognise whether the formfield is in a table or just in
the body of the document? I tried - If rng.Tables(1).Columns.Count > 1
Then... but it doesn't work. I'm not an expert as you can see.
Dim rng As Range
Set rng = Selection.Range
On Error Resume Next
'Unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
If rng.Tables(1).Columns.Count > 1 Then
With rng.Cells(1)
.Range.FormFields(1).Result = Format(ctrlCal.Value, "dd MMM yyyy")
End With
Else: ActiveDocument.FormFields("pfield1").Result = Format(ctrlCal.Value,
"dd MMM yyyy")
End If
Unload Me...
regards
Dylan