WORD how to vary a constant by program

L

Le Nordiste

Hi,

In a .doc i have à UserForm, with some TextBoxes and other controls
too.

I want to populate the TextBoxes with permanent text, so that why i
store this "permanent" text in a constant.
But from time to time it is necessary to vary the "permanent text".

How i can do this thing :
Store permanent text, in order there are usable at each opening of the
file,
and how to be able to modify this pseudo constant string.

Thanks by anticipation.
 
D

Doug Robbins - Word MVP

Store the text in document variables and have code in the userform activate
event to set the .Text property of the controls to the .Value of the
document variables and use code in a command button click event to update
the .Values of the variables with the .Text of the relevant controls.

To store something in a document variable, use

ActiveDocument.Variables("varname").Value = somecontrol.Text

you reverse the statement to retrieve the data from the variable

somecontrol.Text = ActiveDocument.Variables("varname").Value

If you want to display the value assigned to the variable in the document,
use a DOCVARIABLE field.



--
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

Hi,

In a .doc i have à UserForm, with some TextBoxes and other controls
too.

I want to populate the TextBoxes with permanent text, so that why i
store this "permanent" text in a constant.
But from time to time it is necessary to vary the "permanent text".

How i can do this thing :
Store permanent text, in order there are usable at each opening of the
file,
and how to be able to modify this pseudo constant string.

Thanks by anticipation.
 
L

Le Nordiste

Thanks Doug,

Very good : i did not know the "ActiveDocumentVariables" it look as a
versatile solution for some problems.

But one more question, i did n't find how to save
"Act_Doc_Variables("tata") in order to retrieve its new entered value
at the next opening of the .doc.

In other word my search is :
I want to enter a "quasi-constant"value in a someControl.text and to
automatically save it when i close the document - or at any event
before closing, in order to retrieve the later entered value of the
"quasiconstant"


Here in Paris (France) the weather is fine.


Thanks in anticipation.
 
D

Doug Robbins - Word MVP

You do not have to specifically save the variables. If you use code to set
the values of the variables, those values will be saved in variables in the
document when the document is saved.

--
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
 
L

Le Nordiste

I tried and i succeed, after two or three trial.

Thanks -one more time Doug for your explanation
 

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