Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
robert_mika
Master III
Master III

How to add object to container with Grid layout via VBS

As in subject.

I have go thru the API guide but with no luck.

6 Replies
marcus_sommer
MVP & Luminary
MVP & Luminary

This looks like your question:

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\CH03"

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

- Marcus

robert_mika
Master III
Master III
Author

Thanks Marcus.

I have seen this code and have been playing with it but I'm getting error

Object doesn't support this property or method: 'ContProp.ContainedObjects.tem'

under this line

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

I have been trying solution from this post but it has not helped

Macro Create Container Error

Any suggestions?

marcus_sommer
MVP & Luminary
MVP & Luminary

For me it worked with qv 10 fine unless the grid-style which qv 10 didn't have but in qv 11 you will find some grid-options within the api. Have you looked that you have an object with the id "Document\CH03" and you could also try it without the document-prefix "CH03".

- Marcus

robert_mika
Master III
Master III
Author

Still no luck Marcus.

Would you mind to point me in out in the right direction  to find the Grid member for the container in the API file?

marcus_sommer
MVP & Luminary
MVP & Luminary

If I tried this in qv 11 it worked:

sub x

Set ContainerObj = ActiveDocument.Sheets("Automation Examples").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\TX29"

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

end sub

And here are the grid-options. Unfortunately there are no examples for so it will be an ugly trial & error game

- Marcus

sasiparupudi1
Master III
Master III

Sub Export

     Chart1="Document\CH04"

     Chart2="Document\CH02"

     TargetFile="c:\aps\Container.png"

     Call ExportContainer(Chart1,Chart2,TargetFile)

End Sub

Sub ExportContainer(Chart1,Chart2,TargetFile)

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

    set ContProp=ContainerObj.GetProperties

    ContProp.ContainedObjects.Add

    ContProp.Mode=1

    ContProp.GridColumns=2

    ContProp.GridRows=1

    ContProp.ShowObjectTypeIcons=true

    ContProp.ContainedObjects.Add

    ContProp.ContainedObjects.Item(0).Def.ObjectId = Chart1

    ContProp.ContainedObjects.Item(0).Text.v =Chart1

    ContProp.ContainedObjects.Add

    ContProp.ContainedObjects.Item(1).Def.ObjectId =Chart1

    ContProp.ContainedObjects.Item(1).Text.v = Chart1

    ContainerObj.SetProperties ContProp

    ActiveDocument.GetApplication.WaitForIdle

    ContainerObj.ExportBitmapToFile TargetFile

    ContainerObj.Close

End Sub