Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variables

Hi,

is it possible to set the variable with more than one value using the set content through vbscript/macro.

4 Replies
Miguel_Angel_Baeyens

Hello,

One variable will always store only one value. Despite this, you can set a variable to get the value stored formatted so it can be later used in an expression:

SET vLetters = 'A','B','C';


So there's only one value, but formatted so it can be used in some functions or set analysis.

If you mean you want to keep the value stored in one variable and append to it some other value, try something like

Sub AddLetters Set v = ActiveDocument.Variables("vLetters") vOld = v.GetContent.String vNew = "'D'" v.SetContent vOld & "," & vNew, trueEnd Sub


Or better use one Action, External, Set Variable, the name of the variable and the value to

=vLetters & chr(44) & chr(39) & 'E' & chr(39) // Will add ",'E'"


Hope that helps.

Not applicable
Author

Thanks Miguel,

Actual problem i am trying to print the data in the table to textobject . The table has more than one row.

Is there any i can print the value of a table directly in to the text object using macro.

Not applicable
Author

Is that someting like...

sub tst41
'get a field to iterate throught values
set graphIdField = ActiveDocument.Fields("graphId")
set graphIdVals = graphIdField.GetPossibleValues

'create an empty string
str = ""
For i=0 to graphIdVals.Count-1
'concatenate the value of the string to this string
str = str & " " & graphIdVals.Item(i).Text
next

'setting the value to the variable used in the text object
set var = ActiveDocument.getVariable("vText")
var.setContent str, false
end sub

Not applicable
Author

Thanks Renaud.Charlet,

This gave me some idea and i am able to get the required solution .