Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Change Color of Buttons on Click by using macro

Hello everyone

I need to change color of my buttons after they are clicked. I have already a macro triggered by the buttons which hides and shows charts. So I want to add some codes to those macros in order to change colors of buttons.

I have found some related topcis in forum but I could not open any of them. So I would be preciated if someone can send me VB codes.

Thank You

HealMe_Solutions

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

There are many way to do this. Here is an example:
1. Create a variable for color, for example vColor, and use it in your button color (calculated color):
=$(vColor)
2. Macro that switches color:


sub Macro
set c = ActiveDocument.Variables("vColor")
if c.GetContent.string="rgb(255,200,200)" then
c.SetContent "rgb(200,255,200)", true
else
c.SetContent "rgb(255,200,200)", true
end if
end sub

Apparently you can include this code in your existing macros

View solution in original post

6 Replies
Anonymous
Not applicable
Author

There are many way to do this. Here is an example:
1. Create a variable for color, for example vColor, and use it in your button color (calculated color):
=$(vColor)
2. Macro that switches color:


sub Macro
set c = ActiveDocument.Variables("vColor")
if c.GetContent.string="rgb(255,200,200)" then
c.SetContent "rgb(200,255,200)", true
else
c.SetContent "rgb(255,200,200)", true
end if
end sub

Apparently you can include this code in your existing macros

Not applicable
Author

Thank you for your reply Michael.

A last Question. Where Should I create vColor variable, in Load script, in macro VB part or some where in the Button?

Thank You

Anonymous
Not applicable
Author

Not in macro Variables can be created in the script on from front end. In this case, the appropriate way is to use toolbar Setting -> Variable Overview, click Add, type variable name (in this case vColor), and OK.

Not applicable
Author

Nice sharing.

Thanks to all.


ERP Consulting
SAP ERP Consultants

Not applicable
Author

Thank you all. It helped so much...

Not applicable
Author

Hi All,  I have a similar question and I having some trouble inputting this in my macro.  Anyway someone can explain this simplier?