Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
i'm looking for a tips to set a value for more then ten variables.
Now, i'm using a button with action 'set varaible' ten times not really good !!
thanks
I've attached my .qvw if it helps explain my solution above. Basically, it loops through each variable in the document and assigns the same value (based on input box) to those that begin with "vSet". You can play around with the syntax.
Are you setting same value to all of those variables?
Yep
You could write a small macro to set all those variable, but using macros is usually a bad idea.
I would stay using 10 actions
hoo noo
i tried :
VAl1;VAL2;VAL3
or
VAl1,VAL2,VAL3
nothing works
Sub SetVariables
Dim objTempVar, objDestVar, objSourceVar, objSource
varValue = inputBox("Input your value")
varNo = ActiveDocument.GetVariableDescriptions.Count - 1
For i = 0 to varNo
If Left(ActiveDocument.GetVariableDescriptions.Item(i).Name,4) = "vSet" Then
set objTempVar = ActiveDocument.GetVariableDescriptions.Item(i)
varname=Trim(objTempVar.Name)
Set objSourceVar=ActiveDocument.Variables(varname)
varcontent=objSourceVar.GetRawContent
Set objDestVar=ActiveDocument.Variables(varname)
objDestVar.SetContent varValue,true
END IF
Next
End Sub
I don't see anything wrong with multiple actions in one button... In most cases it is better than using macros.
Since you are setting the same value you all variables you could just have the button set 1 variable and then have the other 9 variables equal that first one.
I agree, but when you have a lot of variables !! i've got a report with more then 24 variables.
it's sounds like greate !! i'll try this