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: 
helen_pip
Creator III
Creator III

Can the value of a macro be referenced in a text object?

Dear Qlikview user

I have 1 macro in my Qlikview document which activates some tabs in a container

I have been asked to hide the container tabs and provide the end user with some narrative instead, as to what they have selected

I therefore need to create some narrative in a text object and reference the macro

I.e. 'You have currently selected' & ' ' &  .....ActivateTab(0)...............

Sub ActivateTab(I)

for j = 1 to 2

  Set Obj=ActiveDocument.GetSheetObject("Container_" & j)

  Set ObjProp=Obj.GetProperties

  ObjProp.SingleObjectActiveIndex=I

  Obj.SetProperties ObjProp

  next

end Sub

Sub ActivateTab0()

  ActivateTab(0)

end Sub 

Sub ActivateTab1()

  ActivateTab(1)

end Sub 

Sub ActivateTab2()

  ActivateTab(2)

end Sub

Sub ActivateTab3()

  ActivateTab(3)

end Sub

Sub ActivateTab4()

  ActivateTab(4)

end Sub

Can anyone help me with this?

Kind Regards

Helen

6 Replies
Colin-Albert

Do you actually need a macro to achieve the end result?

If the container tabs are hidden, why use a container at all. Why not put the objects on separate sheets and navigate between the sheets using actions - no need for a macro. You can hide the sheet tabs if you want a clean look & feel.

marcus_sommer

You could create a gui-variable called vActiveContainerTab and then you set/change the value from the macro-side, for example:

...

Sub ActivateTab(I)

for j = 1 to 2

  Set Obj=ActiveDocument.GetSheetObject("Container_" & j)

  Set ObjProp=Obj.GetProperties

  ObjProp.SingleObjectActiveIndex=I

  Obj.SetProperties ObjProp

  next

  ActiveDocument.Variables("vActiveContainerTab").SetContent I, true

end Sub

...

- Marcus

helen_pip
Creator III
Creator III
Author

Hello Marcus

Thank you for your suggestion. I shall certainly give that a try!

However I have 1 macro already loaded into my document, and when I add another macro it tends to override the initial macro

Do you know why Qlikview does this? Or am I not assigning my macro's correctly, as I am just adding them to a text object

Kind Regards

Helen

marcus_sommer

What do you mean with override? What happens and how will be the macros triggered?

- Marcus

helen_pip
Creator III
Creator III
Author

Hello Marcus

Thank you for responding.

My method for macro's is:

Text Object - Action - Add - RunMacro- - Edit Module (This is where I put my macro code)

Then when I want to run another macro, I select a new sheet object - Text Object - Action - Add - RunMacro -  Edit Module (This is where I put my macro code

However when I go back to my original text object, the macro has been overwritten with the new module

Should I be defining my macro's somewhere else in the document

marcus_sommer

It's better to access the modul-editor directly per menu/extras/modul or ctrl + m and there pasting both routines in.

- Marcus