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 / September 2005

Tip: Looking for answers? Try searching our database.

Extracting Field Data Using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 27 Sep 2005 20:26 GMT
Once a document is open in VBA, is it possible to get the data associated
with named reference fields:  For example the document has the following
field:

   {  REF DocNum \h  \* MERGEFORMAT  }

How can I retrieve the value (i.e. 2005-West-11 in this case) using VBA?

Thanks!

Don
Jean-Guy Marcil - 27 Sep 2005 21:02 GMT
Don was telling us:
Don nous racontait que :

> Once a document is open in VBA, is it possible to get the data
> associated with named reference fields:  For example the document has
[quoted text clipped - 4 lines]
> How can I retrieve the value (i.e. 2005-West-11 in this case) using
> VBA?

{  REF DocNum \h  \* MERGEFORMAT  }

refers to a bookmark named " DocNum"

So, in VBA, just get the value of the bookmark itself:

Dim MyBookValueStr As String
MyBookValueStr = ActiveDocument.Bookmarks("DocNum").Range.Text

If you need to extract "DocNum" from the REF field, lookup the Code property
of Fields in the VBA help.

Signature

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

Don - 27 Sep 2005 22:01 GMT
Perfect!  The Fields properties are especially helpful.

Thanks!!

Don

> Don was telling us:
> Don nous racontait que :
[quoted text clipped - 19 lines]
> If you need to extract "DocNum" from the REF field, lookup the Code
> property of Fields in the VBA help.
 
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.