
Setting Bookmark to Variable value
I have a meeting announcement form with two bookmark fields: bMeetingDate
and bRSVPDate. I want the RSVP bookmark to autofill with a date 4 days
before that entered for the meeting date. I have the following code run on
the On Exit of the Meeting Date bookmark:
Sub RSVPDate()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
vMeetingDate = Mid(ActiveDocument.Bookmarks("bMeetingDate").Range, 11,
30) '"strips FormText "
vDateStart = InStr(1, vMeetingDate, " ") 'Get rid of day of week part
vMeetingDate = Mid(vMeetingDate, vDateStart, 30) 'I picked 30 as
being bigger then any date
'so I wouldn't need to calc StrLen type code.
vRSVPDate = DateAdd("D", -4, vMeetingDate) 'Typically Tuesday with
Friday RSVP
vRSVPDate = Format(vRSVPDate, "dddd, MMMM, d, yyyy")
ActiveDocument.FormFields("bRSVPDate").Result =
ActiveDocument.FormFields("bMeetingDate").Result 'WORKS but
returns the same date as the Meeting date
Here is the problem area - I tried each of the lines below, but nothing gets
filled in. In the immediate window I can see that vRSPVDate has the value I
want. How do I set the form field/bookmark bRSVPDate to the value in vRSVP
date?
'ActiveDocument.FormFields("bRSVPDate").Result = vRSPVDate DOESN'T
WORK
'ActiveDocument.Bookmarks("bRSVPDate").Range.Text = vRSPVDate DOESN'T
WORK
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
Thanks,
= Stuart =