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
Simply address the form field by bookmark name. It doesn't then matter where
it is.
See the final example at http://www.gmayor.com/popup_calendar.htm

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> 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
[quoted text clipped - 26 lines]
> regards
> Dylan
dd - 30 May 2008 23:40 GMT
Thanks Graham, problem solved.
popup_calendar.htm was a big help too.
Regards
Dylan
> Simply address the form field by bookmark name. It doesn't then matter
> where it is.
[quoted text clipped - 30 lines]
>> regards
>> Dylan