Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gandalfgray
Specialist II
Specialist II

Function to get Object ID?

Is there a function to get the Object ID of the currently active object?

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try this Code.

   

set s=ActiveDocument.ActiveSheet

for i=0 to s.NoOfSheetObjects-1

    if s.SheetObjects(i).IsActive then

     id = s.SheetObjects(i).GetObjectId

     msgbox("ID = " & id)

End if    

next

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
SunilChauhan
Champion
Champion

please see the attached file

Sunil Chauhan
gandalfgray
Specialist II
Specialist II
Author

Thanks for your suggestions, but it's not possible (as far as I know) to use macro code in for instance the Show Condition statement for an object (a Chart, a Listbox etc), and thats where I would like to use such a function, to be able to write a generic Show Condition statement.

tanelry
Partner - Creator II
Partner - Creator II

You can use Sheet Properties > Triggers > Sheet Object Event Triggers (OnActivate, OnDeactivate) to set variables.

Then use those variables in Show Condition.