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

Add object to a container

Hi,

I'm trying to add an object to a container using a simple MACRO, but it is not working and no error is triggered. I think that it is braking on "objectId" line.
Any ideas?

OPTION EXPLICIT

SUB test

  DIM customFilter

  DIM customFilterProperties

  DIM containedObjects

 

 

  SET customFilter           = ActiveDocument.GetSheetObject("Document\CT01")

  SET customFilterProperties = customFilter.GetProperties

  SET containedObjects       = customFilterProperties.ContainedObjects

  'Lenght

  containedObjects.Add

  containedObjects.Item(0).ObjectId="Document\TX01"

  containedObjects.Item(0).Text.v="Lenght"

 

  customFilter.SetProperties customFilterProperties

 

 

 

END SUB

Example document is attached.

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Found the solution

SUB test

Set ContainerObj =ActiveDocument.GetSheetObject( "CT06" )

set ContProp=ContainerObj.GetProperties

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

 

END SUB

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,

Thanks for your reply. Sorry, I didn't specified that I am using QV 11, so the line below dosen't work. "Id" is obsolete according to the API (that's why I used objectId instead)

lineContProp.ContainedObjects.Item(0).Id = "Document\TX01"

Not applicable
Author

Found the solution

SUB test

Set ContainerObj =ActiveDocument.GetSheetObject( "CT06" )

set ContProp=ContainerObj.GetProperties

ContProp.ContainedObjects.Add

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

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

ContainerObj.SetProperties ContProp

 

END SUB