Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Container Objects in QlikView Macros

I'm running QV 11.2 and trying to run thru the example for "ContainedObjects" / "IContainerProperties":

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

However, I get an error that "Id" is not a supported property. See attachment for clarification.Capture07.PNG

Is this a known problem? Is there any solution?

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

This modified code works. The Id property is obsolete and the Def property with the sub property of ObjectID is the replacement property to use:

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\CH01"
ContProp.ContainedObjects.Item(0).Text.v = "Bar"

ContProp.ContainedObjects.Add
ContProp.ContainedObjects.Item(1).Def.ObjectId = "Document\CH02"
ContProp.ContainedObjects.Item(1).Text.v = "Mekko"

ContainerObj.SetProperties ContProp

View solution in original post

6 Replies
Not applicable
Author

After some more research, I found that you could write this short script:

Set MyApp = CreateObject("QlikTech.QlikView")


In a tool such as vbsedit to get the actual information about the contents of the API. Pretty useful!

It seems like the property was changed to Id_OBSOLETE at some point. This sort of indicates that it should not be used. But changing the example to that, the example actually works.

So why has it been changed? And what is an alternative method of getting the Id's of objects in a Container?

Capture08.PNG

petter
Partner - Champion III
Partner - Champion III

Is this helpful?

2015-10-05 #3.PNG

petter
Partner - Champion III
Partner - Champion III

This modified code works. The Id property is obsolete and the Def property with the sub property of ObjectID is the replacement property to use:

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\CH01"
ContProp.ContainedObjects.Item(0).Text.v = "Bar"

ContProp.ContainedObjects.Add
ContProp.ContainedObjects.Item(1).Def.ObjectId = "Document\CH02"
ContProp.ContainedObjects.Item(1).Text.v = "Mekko"

ContainerObj.SetProperties ContProp
Not applicable
Author

Ah, thanks! How could I miss the Def property?

What I was hoping to do with this info was to get a handle of the Container objects so that I could change some properties on them (like Caption text, background color etc). But that does not seem possible? I can't seem to find a "getobject" method for those objects...

petter
Partner - Champion III
Partner - Champion III

These container objects are "linked" so most of the properties should be changed if you change them ... You just do a GetObject on the "external" objects that you link into the container I would think.

Not applicable
Author

Yes, that works, I've tested that.

The problem is that most often I tend to add objects to a container and then delete them, so they don't exist as "external" objects.