Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Tags (2)
1 Solution

Accepted Solutions

Re: Macro Create Container Error

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

2 Replies

Re: Macro Create Container Error

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

Not applicable

Re: Macro Create Container Error

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!

Community Browser