How to DOCVARIABLE as workaround for 255 char limit in Word 2003

S

surabhi

How to use DOCVARIABLE field code of MS Word placed for a bookmark, to
populate text(including line breaks) of more than 255 characters?

A macro should be called which does not display any form as we require yet
another application, Siebel to call the macro after opening the Word document
through the Siebel escript.

Is ther any syntax/example using objWordDoc.FIELDS.UPDATE
 
P

Pesach Shelnitz

Hi,

When you create the DOCVARIABLE field code in the Word doc, you assign a
name to it. For example, the field code {DOCVARIABLE MyVariable} corresponds
to a variable called MyVariable. A Docvariable is represented by an object
that is an element of the Variables collection and by an object that is an
element of the Fields collection. You assign a value to the Docvariable
through the former, and you update the text displayed by it through the
latter. The following lines perform these operations.

objWordDoc.Variables("MyVariable").Value = myValue
objWordDoc.Fields.Update
 
P

Pesach Shelnitz

Hi,

I omitted something that is very important. You also need to
programmatically create the object that represents the Docvariable in the
Variables collection of the doc before setting the value as follows.

objWordDoc.Variables.Add "MyVariable"

This is done only once for the doc. If your code attempts to create this
object again, it will generate an error.
 
D

Doug Robbins - Word MVP

It is not necessary to create the variable before assigning a value to it.
Your original code is all that is required.

--
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, originally posted via msnews.microsoft.com
 

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