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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top