Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Store OBJECTID in a variable

Hi All,

In the enclosed sample file, I have few objects which need to be "send to excel with caption".
We have the macro for the same which works fine for an object whose objectID is hardcoded in the macro.

The requirement is I need to pass the OBJECTID of the selected chart (one at a time) to the macro through a variable.

Appreciate if someone suggest how do we achieve this?

Thanks,

Kumar

1 Reply
flipside
Partner - Specialist II
Partner - Specialist II

The following code will iterate over every object on a sheet and tell you which objects are active BUT the problem is when you click a button to trigger the macro, the button becomes the sole active object!!

objs=s.GetSheetObjects

for i=lbound(objs) to ubound(objs)

    if objs(i).IsActive then msgbox objs(i).getObjectId & " is active"

next

... not sure if assigning the macros to the menu bar (Macro 1, Macro 2, Macro 3) would fix this, but you also have the issue if multiple objects are selected.

Perhaps you could place all your charts into a container and use the following to identify the chosen chart ...

set ContainerObj = ActiveDocument.GetSheetObject("CT01")

    Set ContProp = ContainerObj.GetProperties

ActiveObject=ContProp.SingleObjectActiveIndex

msgbox "Active Object=" & ActiveObject & "  Id=" & ContProp.ContainedObjects.Item(ActiveObject).text.v

The example in APIGuide shows it should be possible to identify the ActiveObject Id (ContProp.ContainedObjects.Item(0).Id) but this doesn't work in QV11 it seems, you might need to put the actual object ID via the container properties object labels (Objects Displayed in Container).

flipside