4 Replies Latest reply: Mar 9, 2011 2:12 PM by Logesh Jayaraman RSS

    variables

    Logesh Jayaraman

      Hi,

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

        • variables
          Miguel Angel Baeyens de Arce

          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.

            • variables
              Logesh Jayaraman

              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.

                • variables

                   

                  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