Hello,

Can someone tell me how or if it is possible to update a cross reference
field through VBA code. I have a form letter set up. In in, I have a Form
Field with a Bookmark name of "ContactName". I have a Cross Reference field
which I set up by Insert-Reference-Cross Refence and selecting Bookmark as
Refernce type and checked HyperLink.

How can I have this field updated through my code. I tried
ActiveDocument.Fields.Update but this does not work. Would anyone have any
suggestions? Hopefully, I am explaining this correctly.

Thanks.

Re: Updating Cross Reference Fields in VBA by Jean-Guy

Jean-Guy
Wed Oct 04 19:34:13 CDT 2006

sharonm was telling us:
sharonm nous racontait que :

> Hello,
>
> Can someone tell me how or if it is possible to update a cross
> reference field through VBA code. I have a form letter set up. In in,
> I have a Form Field with a Bookmark name of "ContactName". I have a
> Cross Reference field which I set up by Insert-Reference-Cross
> Refence and selecting Bookmark as Refernce type and checked HyperLink.
>
> How can I have this field updated through my code. I tried
> ActiveDocument.Fields.Update but this does not work. Would anyone
> have any suggestions? Hopefully, I am explaining this correctly.
>
> Thanks.

If you are talking about a protected form, you do not need VBA.

Just make sure that you check the "Calculate on Exit" check box in the
formfield properties (by right clicking on the formfield "ContactName")

By the way, activating the Hyperlink option in a protected form is useless
as it will not work when the document is protected.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



RE: Updating Cross Reference Fields in VBA by zkid

zkid
Wed Oct 04 20:30:01 CDT 2006

This code works on both protected and unprotected documents. If you want,
you can leave out the error-checking, but it's handy to let you know if one
of your cross-references no longer has a valid hyperlink:

On Error GoTo ErrorHandler
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview

StatusBar = "Updating fields - please wait..."

Exit Sub

ErrorHandler:

If ActiveDocument.Fields.Update <> 0 Then
MsgBox "Field " & ActiveDocument.Fields.Update & _
" has an error - please check for missing bookmark codes", _
vbInformation, "Updated Fields Prompt"
End If



"sharonm" wrote:

> Hello,
>
> Can someone tell me how or if it is possible to update a cross reference
> field through VBA code. I have a form letter set up. In in, I have a Form
> Field with a Bookmark name of "ContactName". I have a Cross Reference field
> which I set up by Insert-Reference-Cross Refence and selecting Bookmark as
> Refernce type and checked HyperLink.
>
> How can I have this field updated through my code. I tried
> ActiveDocument.Fields.Update but this does not work. Would anyone have any
> suggestions? Hopefully, I am explaining this correctly.
>
> Thanks.
>