Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Changing value of variable

I wonder if someone can help.

I set up a variable in script: LET vZoom=0;

I'm trying to create a button that will toggle the value of the variable between 0 and 1 every time I press it by running the following macro:

SUB Zoom_Toggle()
Select Case vZoom
Case 1
vTest=0
Case 0
vTest=1
End Select
ActiveDocument.Variables("vZoom").SetContent vTest, true
END SUB

However, the button only seems to change the value the first time I press it and stops working.

Am I missing something?

Thanks for helping

1 Solution

Accepted Solutions
Not applicable
Author

Excellent. .Number didn't work but I found that .String did and now the button works perfectly.

Cheers!

View solution in original post

2 Replies
Not applicable
Author

You're not referencing the variable correctly in your Case.

SUB Zoom_Toggle()
Select Case ActiveDocument.Variables("vZoom").GetContent.Number
Case 1
vTest=0
Case 0
vTest=1
End Select
ActiveDocument.Variables("vZoom").SetContent vTest, true
END SUB


I think it is .Number there.

Not applicable
Author

Excellent. .Number didn't work but I found that .String did and now the button works perfectly.

Cheers!