Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, All!
I have a Container with two tabs (two different tables inside). How could I using macro select one tab or another (accordingly user will see one table or another)?
Thanks.
Yes, I have a number of buttons each for activating a spesific tab in a container.
Just in the "actions" section of the button properties, I selected "run macro" and specified the macro name there.
Regards,
Add a Button to trigger the Macro.
First you have to Set Variable to pass to the macro as it is not allowed to pass variables in the macro call. (vMCont and vMTab)
vMCont = container Object ID
vMTab = See Container - General - Label for Selected Item
Run macro = SetTabInContainer
Paste following code in to the macro editor
Sub SetTabInContainer
Set Container = ActiveDocument.Variables("vMCont")
Set Tab = ActiveDocument.Variables("vMTab")
Call InteranlSetTabInContainer(Container.GetContent.string,Tab.GetContent.string)
end sub
Sub InteranlSetTabInContainer (Container, Cname)
NewIndex = 0
Set ContainerObj = ActiveDocument.GetSheetObject(Container)
set ContProp=ContainerObj.GetProperties
for i = 0 to ContProp.ContainedObjects.Count - 1
if ContProp.ContainedObjects.Item(i).Text.v = Cname then
NewIndex = i
End IF
next
ContProp.SingleObjectActiveIndex = NewIndex
ContainerObj.SetProperties ContProp
end Sub
This was an issue that I brought up to R&D a while ago. Those who are using certain versions QlikView will notice that these properties no longer produce the desired result. The API for getting the active object and changing the active object programmatically can be found in this article with examples: https://support.qlik.com/articles/000070090