Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Is this a known problem? Is there any solution?
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 |
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?
Is this helpful?
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 |
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...
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.
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.