Setting Bookmark to Variable value 
Author Message
 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 =



Sat, 22 Jan 2005 07:11:05 GMT  
 Setting Bookmark to Variable value

you cannot change a result field, use:

ActiveDocument.Bookmarks(1).Range.Text="Chuck a bewdy"


this:

Quote:
>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 =

Steve Hudson - Word Heretic, Sydney, Australia
{*filter*} teacher, trainer, tutor, writer, developer

You agree by writing to me personally that any material can be reused publicly unless you explicitly disclaim it. (For List and blog use.)


Sat, 22 Jan 2005 07:52:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Bookmark(2).value from other bookmark

2. Set Variable = Field Value

3. Setting a variable to the largest record value.

4. Create an AutoTextEntry with it's value set to a document variable

5. Set many "values" to variables

6. How do I set a static variable value?

7. Set a text file as variable value

8. Setting the value of a server variable from a client script

9. Setting variable values

10. How to set a null value for a data variable

11. How do you set the initial value of a Static variable

12. The value of a variable (String type) is the name of a variable

 

 
Powered by phpBB® Forum Software