Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
AbhijitBansode
Specialist
Specialist

Problem with container object in QV10

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.

1 Solution

Accepted Solutions
stephencredmond
Luminary Alumni
Luminary Alumni

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

View solution in original post

16 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

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

stephencredmond
Luminary Alumni
Luminary Alumni

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

AbhijitBansode
Specialist
Specialist
Author

thanks stephen,

i's missing to call SetProperties at last on Container object.

Now my problem is solved.

ramonarcusa36
Contributor III
Contributor III

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!!

AbhijitBansode
Specialist
Specialist
Author

yes , qlikview version might be the problem.

I'm using QV10 SR2.

I'm also not sure Whether QV10 SR1 supports this property.

Not applicable

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.

Not applicable

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

AbhijitBansode
Specialist
Specialist
Author

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

Not applicable

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