Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Updating Cross Reference Fields in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sharonm - 05 Oct 2006 01:18 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.