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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

qlikview macro : how to display specific object in an empty container

I am new to macros.

I am exploring macros to show a tablebox ( i know the object id ) into a new empty container by just clicking a button.

Is there a way to do it?

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

There is a macro for that:

Sub Container

Set Obj = ActiveDocument.Sheets("Main").CreateContainer

'or Set Obj = ActiveDocument.GetSheetObject("CT01")

Set Prop = Obj.GetProperties

Prop.ContainedObjects.Add

Prop.ContainedObjects.Item(0).Def.ObjectId= "Document\TB01"

Obj.SetProperties Prop

End Sub

To go along with what Michael Solomovich says, I would only use a macro as a last resort. If there is a way without macro, then use that way instead.

Hope this helps!

View solution in original post

9 Replies
Anonymous
Not applicable
Author

Parth,

Are you sure you need a macro?  Create a container, add objects you need, including the table box.  Container has it's "natural" buttons to show the object.  If you want to have an "Empty" container, add a text box with no text (or some help text) and caption "Empty".

Regards,

Michael

jerem1234
Specialist II
Specialist II

There is a macro for that:

Sub Container

Set Obj = ActiveDocument.Sheets("Main").CreateContainer

'or Set Obj = ActiveDocument.GetSheetObject("CT01")

Set Prop = Obj.GetProperties

Prop.ContainedObjects.Add

Prop.ContainedObjects.Item(0).Def.ObjectId= "Document\TB01"

Obj.SetProperties Prop

End Sub

To go along with what Michael Solomovich says, I would only use a macro as a last resort. If there is a way without macro, then use that way instead.

Hope this helps!

Not applicable
Author

Thanks Michael. Sorry I am really new to QlikVIew, so I didnt know about this feature.

Not applicable
Author

Awesome. Thank you so much

Not applicable
Author

Similarly, is there a way to remove an object ?
Where do I get API for viewing all the methods?

jerem1234
Specialist II
Specialist II

Yea something like:

ActiveDocument.GetSheetObject("TX01").Close

I attached the API Guide qvw which will be helpful when writing macros. It takes some getting used to though.

Hope this helps!

Not applicable
Author

Thanks..!!

I was trying to remove an object from container (which still keeps the object in a sheet).

Set Obj = ActiveDocument.GetSheetObject("CT01")

Set Prop = Obj.GetProperties

if Prop.ContainedObjects.Count <> 0 Then

Prop.ContainedObjects.Item(0).Remove

Obj.SetProperties Prop

end if

I does not seem to work.

jerem1234
Specialist II
Specialist II

Try this:

Set Obj = ActiveDocument.GetSheetObject("CT01")

Set Prop = Obj.GetProperties

if Prop.ContainedObjects.Count <> 0 Then

Prop.ContainedObjects.RemoveAt(0)

Obj.SetProperties Prop

end if

Not applicable
Author

Awesome. It worked. Thank you so much.. I guess I have to get used to APIguide.qvw. It was a great start so far.
Thanks again..