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

Macro Create Container Error

Hello,

I hope someone can help, I am trying to create a new container object and assign some objects into it.

The below code I have copied directly out of the QV11 API and it just wont work. I have updated the 2 object ID's to 2 List Boxes I have on my page but when I run it the edit module window opens. The container itself is create but not the objects are not put in place.

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

set ContProp=ContainerObj.GetProperties

ContProp.ContainedObjects.Add

ContProp.SingleObjectMode=1

ContProp.SingleObjectStyle=1

ContProp.ShowObjectTypeIcons=true

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(0).Id = "Document\LB06"

ContProp.ContainedObjects.Item(0).Text.v = "Test1"

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(1).Id = "Document\LB05"

ContProp.ContainedObjects.Item(1).Text.v = "Test2"

ContainerObj.SetProperties ContProp

1 Solution

Accepted Solutions
MayilVahanan

HI

Try like this

Sub Test

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

set ContProp=ContainerObj.GetProperties

ContProp.ContainedObjects.Add

ContProp.SingleObjectMode=1

ContProp.SingleObjectStyle=1

ContProp.ShowObjectTypeIcons=true

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(0).Def.ObjectId= "Document\LB11"

ContProp.ContainedObjects.Item(0).Text.v = "Test1"

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(1).Def.ObjectId = "Document\LB10"

ContProp.ContainedObjects.Item(1).Text.v = "Test2"

ContainerObj.SetProperties ContProp

End sub

hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

HI

Try like this

Sub Test

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

set ContProp=ContainerObj.GetProperties

ContProp.ContainedObjects.Add

ContProp.SingleObjectMode=1

ContProp.SingleObjectStyle=1

ContProp.ShowObjectTypeIcons=true

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(0).Def.ObjectId= "Document\LB11"

ContProp.ContainedObjects.Item(0).Text.v = "Test1"

ContProp.ContainedObjects.Add

ContProp.ContainedObjects.Item(1).Def.ObjectId = "Document\LB10"

ContProp.ContainedObjects.Item(1).Text.v = "Test2"

ContainerObj.SetProperties ContProp

End sub

hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thank you very much that now works perfectly!

Is there a new API or anything that shows these functions?

I have one more question...the above example is for a single object. Is there a way of creating mutiple objects? so to use the grid view of a container?

Thanks again for your help!