Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Add SheetObject (Straight-Table) to Container with Macro

Hello together,

I´m trying to add a straight-table Object to a Container-Object with a Macro. The API-Guide provides the following example for this:

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

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

If I try to run the macro, I get an Error at the line "ContProp.ContainedObjects.Item(0).Id" with the Message

"Object does not support this this Property or Method: 'ContProp.ContainedObjects.Item(...).Id'

I´m currently using QlikView 11.20 SR 13. Did anybody get a similar macro to run or has an Idea why it fails ? Unfortunatelly the API-Guide is not complete for working with Containers, I don´t know where to get further Infomation about that.

I attached an example with two charts an the macro, which anybody could try.

Thanks in Advance !

Best Regars

Florian

1 Solution

Accepted Solutions

Re: Add SheetObject (Straight-Table) to Container with Macro

Hi Florian,

Try this,

Sub Container

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

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

End Sub

3 Replies
Highlighted

Re: Add SheetObject (Straight-Table) to Container with Macro

Re: Add SheetObject (Straight-Table) to Container with Macro

Hi Florian,

Try this,

Sub Container

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

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

End Sub

sasiparupudi1
Honored Contributor III

Re: Add SheetObject (Straight-Table) to Container with Macro

Try following

Sub AddChartsToContainer

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

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

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

END SUB