Track Changes & Doc Variables

S

Stefan_B

Hello,

I've recently created a document, which is currently using Doc Variable and
I notice that when I click on the actual 'Doc Variable/Field Code' and edit
the text, save the document and reopen it - the 'Doc Variable/Field Code' has
reset it's self to it's previous information.

Is their any way that when I click on the DocVariable/Field Code that it
will allow me to make these edits - without changing the text, when the
document is reopened. I think it's happening because of the variable in the
code, however I'm not sure how to get over the problem.

Any ideas?

Thanks,
Stefan_B.
 
H

Helmut Weber

Hi Stefan,

you could use a windowselectionchange-event.
See:
http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

Only in principle:
in the event, you could check, if there is only 1 field selected:
If Selection.Fields.Count = 1
if this field is of type wdFieldDocVariable:
if Selection.Fields(1).Type = wdFieldDocVariable
if so display an inputbox
s = InputBox("Newvalue")
assign the new value to the variable:
ActiveDocument.Variables("Testvar").Value = s
and update the field or all fields, like in this example:
ActiveDocument.Fields.Update
---

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
Top