Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want manage objects on sheet (detach/clone/remove). But I don't know how to get ObjectID of active object.
I can save ObjectID for existing objects (I save it with trigger onActivate). But if I clone object, I will not know ObjectID of new object.
Can somebody help me?
Thank you beforehand
Hi, Irina, ObjectID assigned in order for each object. if there is an object CH10, then your new (cloned) object will CH11
It's true only if cloned object was last object. If there is no object CH11.
In case I have objects CH10, CH11, CH12 then I clone CH10, new object will CH13. But I can't know what ObjectID in a sheet last
Irina I can't find function which can calculate Max Object ID, but I created small example, I hope it can help you. 🙂
Your example is very useful, but not in my case... I need clone different charts. Even if I would create new objects with your method, I must know properties of active object, what I clone...
Any way thank you, Anatoly.
Or you can use GetSheetObjects function and calculate this value:
Objects = ActiveDocument.ActiveSheet.GetSheetObjects
For i = lBound(Objects) To uBound(Objects)
If Objects(i).GetObjectType = 10 Then 'pivot tables
set Pivot = Objects(i)
msgbox(Pivot.GetObjectId)
end if
next
Can you post your qvw example ? I can't understand what you need.
I attach my example. I can clone active old objects and detach/attach it. But I can't remove new cloned objects because I don't know it's IDs
see in attached file.
the first chart in cycle - is your new object. "Pivot" it's your new sheet object. and you can manage it.
select object_id('schemaname.objectname') as 'Object Id'
Default schema is dbo
Object Name may be table name,trigger name,view name etc..
Best of Luck