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.
Jean-Guy Marcil - 05 Oct 2006 01:34 GMT
sharonm was telling us:
sharonm nous racontait que :
> Hello,
>
[quoted text clipped - 9 lines]
>
> 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.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
zkid - 05 Oct 2006 02:30 GMT
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
> Hello,
>
[quoted text clipped - 9 lines]
>
> Thanks.