Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
Kunkulis
New Contributor III

Macro to Hide/Show chart object

Hi,

I am trying to get a macro that will adjust the Chart Properties -> Layouy -> Show Conditional to be 1=0 or a variable

This is the code I found, but it keeps failing at cp.Layout.Frame.Show.Always=false 
If i comment it out it will fail at Expression.v

Sub HideIt
Set Obj=ActiveDocument.GetSheetObject("CH421")

     Set cp=Obj.GetProperties

     cp.Layout.Frame.Show.Always = false

     cp.Layout.Frame.Show.Expression.v = "1=0"

     Obj.SetProperties cp

End sub

 

Any idea how to solve this?

Labels (2)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Macro to Hide/Show chart object

I think using a second action/button has no benefit and therefore I would integrate it into the export-routine. Quite useful is also often to add a wait- an/or a sleep-statement between the various actions (show/hide, various selections, copy & paste per clipboard, opening/saving files and so on) to ensure that the objects are calculated/rendered respectively that the OS has enough time to perform these actions.

ActiveDocument.GetApplication.WaitForIdle

rem ** let QV sleep for 10 seconds **
ActiveDocument.GetApplication.Sleep 10000

Quite useful for all the macro-stuff is the APIGuide.qvw within your installation-folders (somewhere by automation) which provides a lot of backgrounds and examples.

- Marcus

View solution in original post

7 Replies
MVP & Luminary
MVP & Luminary

Re: Macro to Hide/Show chart object

I think there are better way to show/hide objects respectively parts of it than using macros. For example you could use a selection - from an extra field - or a variable which is controlled per inputbox or an action - directly included within the UI properties.

- Marcus

Kunkulis
New Contributor III

Re: Macro to Hide/Show chart object

Hi, 

Thank you for the response. I excluded some information, sorry.

I need the graph to be un-hidden for a macro that copies a number of charts to a PPT.
For the PPT I use the CH421, but for the people to view it before copying I have the same chart, but with legend, different size, etc.

The macro that does all the copy work, doesn't copy CH421 if it is hidden with expression 1=0, once it is unhidden, it works.

So the idea is to Unhide the CH421 as the macro starts and hide it as it finishes.

MVP & Luminary
MVP & Luminary

Re: Macro to Hide/Show chart object

Ok. In this case I would change the variable-value with the macro and not adjusting the chart-properties like:

ActiveDocument.Variables("varShowHide").SetContent 0, true

respectively

ActiveDocument.Variables("varShowHide").SetContent 1, true

- Marcus

Kunkulis
New Contributor III

Re: Macro to Hide/Show chart object

You mean as the button is clicked it runs the macro and sets variable?

Or the ActiveDocument.Variables("varShowHide").SetContent 0, true is somehow implemented in the macro? 

Sorry, I am fairy new in the QlikView. So If you could, please, explain as simply as possible.

Thank you in advance.

-Kunkulis

MVP & Luminary
MVP & Luminary

Re: Macro to Hide/Show chart object

I think using a second action/button has no benefit and therefore I would integrate it into the export-routine. Quite useful is also often to add a wait- an/or a sleep-statement between the various actions (show/hide, various selections, copy & paste per clipboard, opening/saving files and so on) to ensure that the objects are calculated/rendered respectively that the OS has enough time to perform these actions.

ActiveDocument.GetApplication.WaitForIdle

rem ** let QV sleep for 10 seconds **
ActiveDocument.GetApplication.Sleep 10000

Quite useful for all the macro-stuff is the APIGuide.qvw within your installation-folders (somewhere by automation) which provides a lot of backgrounds and examples.

- Marcus

View solution in original post

Kunkulis
New Contributor III

Re: Macro to Hide/Show chart object

I added the sleep in the initial macro, but it still failed.

None the less, I found the API Guide, which seems to be very promising, thank you for that, didn't know something like this exists. 

MVP & Luminary
MVP & Luminary

Re: Macro to Hide/Show chart object

Maybe it wasn't clear enough. The variable "varShowHide" needs to be created and set within the visibility-properties before executing the macro.

The sleep-statement is for inter-acting with the OS and the wait-statement for the calculations in QV.

- Marcus