Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Kunkulis
Creator
Creator

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
marcus_sommer

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
marcus_sommer

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
Creator
Creator
Author

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.

marcus_sommer

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
Creator
Creator
Author

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

marcus_sommer

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

Kunkulis
Creator
Creator
Author

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. 

marcus_sommer

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