View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default docvariable, template (.dot)

A DOCVARIABLE /field/ gets its value from a Word Document Variable,
which would typically be created and populated by a bit of VBA code.

For example, there may be some Access VBA code which
a. opens the template, or a document based on the template
b. uses some code like

objDoc.Variables("the variable name").Value = some string value
obtained from the relevant table/field in Access

It is quite possible that "the variable name" would be the same as the
Access column name, e.g. if you had a column in Access caled "mycolumn",
you might have

objDoc.Variables("mycolumn").Value = that string value

You would insert that value into the document using a field such as
{ DOCVARIABLE mycolumn }

There would also typically be some code to deal with the situation where
the Word Document Variable does not already exist.

So...you probably need to identify where that code is and modify it so
that it sets up/maintains a Word Document Variable called "mycolumn".

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

On 07/10/2009 18:28, Paul wrote:
Hello
I have inherited a Word document template (.dot) that contains docvariable
fields in it that are populated from a VB-interface/Access database. I am
told that the application/DB push the data to this template, unlike a mail
merge (I believe).

My question is that I would like to add a new docvariable field and am able
to. However, after creating it, the field is displayed with the error
stating, "Error! Document variable not defined."

I am wondering how this field is associated with a specific field in the
database? The existing fields in the template all have past values in them.

Paul