Finding and reading a DOCVARIABLE

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

[This supersedes my earlier posting about a powerpoint tag.]

When I do Insert > Field in Word, and insert a DOCVARIABLE with the name of
the variable, the resulting field looks like this:

{DOCVARIABLE "VarName" \*MERGEFORMAT}

I can find one of these using this:

Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:=
"DOCVARIABLE"

The above statement leaves the cursor at the field's location, but I don't
know how to use the variable. I need to read the name of the doc variable, do
something wtih it, and show the value in my text. Is this possible? Any other
way to do this?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200810/1
 
D

Doug Robbins - Word MVP

To assign a value to a document variable, you must use VBA

ActiveDocument.Variables("VarName").Value = "Something"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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