Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hide TextObject through Macro

Hi There,

  Have list of text box arranged horizontally. Based on condition, I need to hide one of text box and re-arrange itself to fill hidden text object. Can this be achieved through Macro?

eg.,

If vShow=1

                  Text 1 - Text 2 - Text 3 - Text 4

if vShow = 2

                  Text 1 - Text 2 - Text 4

Notice the Text 3 is hidden and Text 4 gets re positioned to follow Text 2

We can hide Text Objects through layout properties Show > Condition. But how do we change position of the other text box?

So thought of using Macro completely to hide and re-position. If found following API would help to re-position text object.

What is the API that would allow us to hide a text object?

Sub repositionTextObj

set txtObj = ActiveDocument.GetSheetObject( "TX01" )

set grapos = txtObj.GetRect

grapos.Left = 300

txtObj.SetRect grapos

End Sub

Do we have API to access textbox object Show > Conditionally property?

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

set obj = ActiveDocument.GetSheetObject(strNewObjectID)

set prop = obj.GetProperties

prop.Layout.Frame.Show.Expression.v = Your condition here

obj.SetProperties prop

View solution in original post

2 Replies
m_woolf
Master II
Master II

set obj = ActiveDocument.GetSheetObject(strNewObjectID)

set prop = obj.GetProperties

prop.Layout.Frame.Show.Expression.v = Your condition here

obj.SetProperties prop

Not applicable
Author

Thanks Mike. I tried following and it works.

  Set FD = TxtObj.GetFrameDef

  FD.Show.Always = False

  FD.Show.Expression.v = "1 = 2"

  TxtObj.SetFrameDef FD

Now I have following questions

1) As I am not familiar with VB scripts, I tried Java Script (Edit Module > Scripting Engine > JScript) with following test code. It always fails saying 'Qv' is undefined. Any idea?

Init = function() {

    var doc = Qv.GetCurrentDocument();

    var txt = doc.GetObject("TX001");

    alert(txt.GetText());

}

Reference for JScript API JsDoc Reference - Qv