Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Need to change active object in the container by using macro.
There are four charts in the container object viz.,Yearly,Half-Yearly,Quarterly,Monthly.
Time Format,selection list box contains Yearly,Half-Yearly,Quarterly,Monthly as possible values.
depending upon selection in the list box, active object of the container should change.
I've gone through the APIGuide app for the same and found the below code:
Set ContainerObj = ActiveDocument.GetSheetObject("CT01")
set ContProp=ContainerObj.GetProperties
ActiveObject=ContProp.SingleObjectActiveIndex
ActiveObject is giving the index of currently active object in the container.
I can also assign value to this property Like,
ContProp.SingleObjectActiveIndex=0 i.e. 1st object should get active.
but this script does not server the purpose.
need urgent help on this.
Sorry,
Should be something like:
Set ContainerObj = ActiveDocument.GetSheetObject("CT01")
set ContProp=ContainerObj.GetProperties
ContProp.SingleObjectActiveIndex = vNewTab
ContainerObj.SetProperties ContProp
The SingleObjectActiveIndex is a zero based index of the tabs in the container.
Stephen
Hi,
That should work, but once you have made changes to the properties, you need to called the SetProperties function to apply them to the object:
Set ContainerObj = ActiveDocument.GetSheetObject("CT01")
set ContProp=ContainerObj.GetProperties
ActiveObject=ContProp.SingleObjectActiveIndex
ContainerObj.SetProperties ContProp
Regards,
Stephen
Sorry,
Should be something like:
Set ContainerObj = ActiveDocument.GetSheetObject("CT01")
set ContProp=ContainerObj.GetProperties
ContProp.SingleObjectActiveIndex = vNewTab
ContainerObj.SetProperties ContProp
The SingleObjectActiveIndex is a zero based index of the tabs in the container.
Stephen
thanks stephen,
i's missing to call SetProperties at last on Container object.
Now my problem is solved.
Hi you all.
I need to do something similar... but it looks like my Qlikview version (10.00.8815.6 SR1) does not support the SingleObjectActiveIndex property. I just copied Stephen Redmond's code, which looks perfect, but it gets stuck at that line, saying that object does not support this property or method.
Am I doing anything wrong or it's just about my version? Which version do you guys use?
Thanks!!
yes , qlikview version might be the problem.
I'm using QV10 SR2.
I'm also not sure Whether QV10 SR1 supports this property.
I couldn't get this macro to work in QV 10 ... now I'm on QV 11. I'm not sure what's wrong. Could you post a small QV 11 app with your macro? Thanks. I would greatly appreciate it.
Hi,
I got this macro syntax from somewhere else in the community, and it works fine as a macro.
Now my question is how can you cause this macro to run, whenever I choose a different container tab, so I can grab it's index ?
Any idea ?
Thanks,
Yigal
Go to sheet properties -> Triggers(Tab) -> Sheet Object Event Triggers -> Select ObjectID of container object -> and run the macro u have on "On Activate" Event of the selected container object.
Hope this helps..
Thanks,
Spartan
Hi,
This is almost the correct answer...
This works whenever the container object is activated.
But what I need is to let the macro run, every time I press a different tab in the container.
Anyway, thanks for the prompt response.
Yigal