Extracting Field Data Using VBA

D

Don

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
 
J

Jean-Guy Marcil

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
the following field:

{ REF DocNum \h \* MERGEFORMAT }

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.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top