Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a macro to export some data from QlikView to Excel. In QlikView I have a multibox with a table column called "Cycle" which can take the following values:"Cycle 1","Cycle 2","Cycle 3" or none of these values. How can I change what my macro does, depending on whether I have selected a Cycle value or not, and the value of the said Cycle value?
Here you go. Note that your Getvariable syntax is also not correct.
SET cycle_flag = Activedocument.Fields("Name Of Your Field").GetSelectedValues
if cycle_flag(i).text = "Cycle1" then
Start_value = ActiveDocument.GetVariable("Cycle1_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle1_stop").GetContent.String
else
if cycle_flag(i).text = "Cycle2" then
Start_value = ActiveDocument.GetVariable("Cycle2_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle2_stop").GetContent.String
else
if cycle_flag(i).text = "Cycle3" then
Start_value = ActiveDocument.GetVariable("Cycle3_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle3_stop").GetContent.String
end if
end if
end if
Now I'm getting an "Invalid procedure call or argument" error...
Here's the whole code:
set cycle_value = ActiveDocument.Fields("Cycle").GetSelectedValues
if cycle_value(i).text = "Cycle1" then
Start_value = ActiveDocument.GetVariable("Cycle1_start")
End_value = ActiveDocument.GetVariable("Cycle1_stop")
else
if cycle_value(i).text = "Cycle2" then
Start_value = ActiveDocument.GetVariable("Cycle2_start")
End_value = ActiveDocument.GetVariable("Cycle2_stop")
else
if cycle_value(i).text = "Cycle3" then
Start_value = ActiveDocument.GetVariable("Cycle3_start")
End_value = ActiveDocument.GetVariable("Cycle3_stop")
end if
end if
end if
Mihai,
I have already updated the above code.
set cycle_value = ActiveDocument.Fields("Cycle").GetSelectedValues
if cycle_value(i).text = "Cycle1" then
Start_value = ActiveDocument.GetVariable("Cycle1_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle1_stop").GetContent.String
else
if cycle_value(i).text = "Cycle2" then
Start_value = ActiveDocument.GetVariable("Cycle2_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle2_stop").GetContent.String
else
if cycle_value(i).text = "Cycle3" then
Start_value = ActiveDocument.GetVariable("Cycle3_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle3_stop").GetContent.String
end if
end if
end if
There seems to be an error at the : if cycle_value(i).text = "Cycle1" then
I think you have not selected any values in the Cycle field or you must be selecting multiple values.
I have multiple values selected in a multi-box, but only one selected in the Cycle field. Could that be the issue?
Can you try this script and let me know whether you are getting any error message or not.
If ActiveDocument.Fields("Cycle").GetSelectedValues.Count = 0 Then
Msgbox "Nothing is selected"
Else
if ActiveDocument.Fields("Cycle").GetSelectedValues.Count >1 Then
Msgbox "Multiple Values Selected"
Else
set cycle_value = ActiveDocument.Fields("Cycle").GetSelectedValues
if cycle_value(i).text = "Cycle1" then
Start_value = ActiveDocument.GetVariable("Cycle1_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle1_stop").GetContent.String
else
if cycle_value(i).text = "Cycle2" then
Start_value = ActiveDocument.GetVariable("Cycle2_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle2_stop").GetContent.String
else
if cycle_value(i).text = "Cycle3" then
Start_value = ActiveDocument.GetVariable("Cycle3_start").GetContent.String
End_value = ActiveDocument.GetVariable("Cycle3_stop").GetContent.String
end if
end if
end if
End If
End If
I've run your script but I didn't got any message. At all.
I've managed to solve the error by simply replacing cycle_value(i).text with cycle_value(0).text. I will mark your first answer as the correct. Thank you for all the help!
My bad. Glad that you found the mistake. Have a nice day!