PreviousNext
Help > Programming with LAUNCHER Office > LNCCMD commands > Commands list > WSETVAR command
WSETVAR command

Assigns a value to a document variable in the current Word document.

 

Syntax

 

CHGVAR

VAR(&CMD) VALUE('WSETVAR')

CHGVAR

VAR(&PARM1) VALUE('

[Variable="Variable name"]
[;Value="Value"]
[;Update=True/False]

')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

Parameters

Parameters

 

Parm1

Variable: Name of the variable of the document.
If no name is specified, only the Update property will be taken into consideration.

Value: The text to assign to the variable.

Update: Allows you to update all fields and variables in the document if True is specified. 

 

Parm2

 

Parm2 can contain the value to be assigned to the variable if it was not given in Parm1.

 

 

Note

The Word document variable, modified by the WSETVAR command, can then be used in VBA code.

Suppose we execute the following commands:

LNCCMD CMD (WSETVAR) PARM1 ('variable = "A"; value = "100"')

LNCCMD CMD (WSETVAR) PARM1 ('VARIABLE = "B"; VALUE = "3"')

In VBA, variables can be retrieved as follows:

ActiveDocument.Variables.Item( "A")

ActiveDocument.Variables.Item( "B")

Example

 

In this example the "Sir" value is assigned to the "Civil" variable.

 

CHGVAR

VAR(&CMD) VALUE('WSETVAR')

CHGVAR

VAR(&PARM1) VALUE('Variable="Civil";Value="Sir"')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

 

 See also

WREFVAR