Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to export the chart to excel of active object and am able to do using below code,
Shtobj = ActiveDocument.ActiveSheet.GetSheetObjects
for i = lBound(Shtobj) to uBound(Shtobj)
msgbox(Shtobj(i).GetObjectId)
'msgbox(Shtobj(i).IsMinimized)
next
Now am getting the hidden object as well. How to avoid those object in macro?
Regards,
Sivaraj
rem ** fetch invisible objects on active sheet **
ActiveDocument.ActiveSheet.AdjustOffScreenObjects
This will give you list of all hidden objects.
you can check by using If statement, to include this object in export or not.
Sorry to misguide you. above technique will not work.
I've a workaround to achieve this:
'set the Id of the hidden objects with same naming convention
'lets say Ids of all hidden object starts with HDN_*
Sub Test
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
'get id of the object
msgbox(objs(i).GetObjectId)
'Now check if Object Id contains text HDN
'if it contains
'don't include object in export
'else
' include object in export
Now
next
end sub
if you do't want to deal with Object Ids then other option is also available , deal with the object caption
msgbox(objs(i).GetCaption.Name.v)
I am showing the objects conditionally. Adding header to id or caption will not work in my scenario. If we find hidden objects then it will be fine.
It seems that there is really no method to read the condition-state if an object is hidden or not (maybe it's only not documented but to find the correct syntax won't be funny).
Alternative approaches could be to read the GetObjectmemoryUsage or GetObjectCalcTime or to call any object-feature which will fail (maybe a print) and handle it with an OnError-statement. But I think it would be quite difficult so that the suggestion from Abhijit Bansode could be the easiest way - maybe with an expression inside the caption with the same condition how on the visibility - if(condition=true,caption,hidden).
- Marcus