Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

New Contributor III

Re: Select Tab in the Container using Macro

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.


Not applicable

Re: Select Tab in the Container using Macro

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


ContProp.SingleObjectActiveIndex = NewIndex
ContainerObj.SetProperties ContProp

end Sub     


Re: Select Tab in the Container using Macro

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