Determine which IDW sheet has inserted OLE-object (Excel Workbook)

Determine which IDW sheet has inserted OLE-object (Excel Workbook)

Maxim-CADman77
Advisor Advisor
555 Views
5 Replies
Message 1 of 6

Determine which IDW sheet has inserted OLE-object (Excel Workbook)

Maxim-CADman77
Advisor
Advisor

I'm composing iLogic rule for checking IDWs on empty sheets.

It works just fine for most cases except those sheets that contain only OLE objects.

I've found the way to get all OLE references of the Drawing:

Dim oDoc As DrawingDocument = ThisDoc.Document
If ThisDoc.Document.ReferencedOLEFileDescriptors.Count>0 then
	For each oRefOLEfd As ReferencedOLEFileDescriptor in ThisDoc.Document.ReferencedOLEFileDescriptors
		MsgBox (oRefOLEfd.FullFileName)
	Next
End If

But I can't find any property in "Sheet object" page of API help that has any relation to OLE.

Any ideas?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
556 Views
5 Replies
Replies (5)
Message 2 of 6

frederic.vandenplas
Collaborator
Collaborator

Hi @Maxim-CADman77

most objects has a parent object, in this case it is the sheet it is placed on.

The best way to find these objects is to use vba and put a break on the line, in debug mode you'll find what you need...

MsgBox (oRefOLEfd.Parent.ActiveSheet.Name)

 Vba code

Sub test()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
If oDoc.ReferencedOLEFileDescriptors.Count > 0 Then
Dim oRefOLEfd As ReferencedOLEFileDescriptor
    For Each oRefOLEfd In oDoc.ReferencedOLEFileDescriptors
       ' MsgBox (oRefOLEfd.FullFileName)
        MsgBox (oRefOLEfd.Parent.ActiveSheet.Name)
    Next
End If
End Sub
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 3 of 6

Maxim-CADman77
Advisor
Advisor

My test sample  has OLE object inserted in 2nd sheet of three-sheet drawing.

But code you've suggested will returns Name of sheet 1 or 3 if those are active...

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 6

frederic.vandenplas
Collaborator
Collaborator

You are right, it seems just to point the active sheet.

OLE references are found under document, but no info regarding the sheets, so i guess the api is not exposed for this...

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 5 of 6

Maxim-CADman77
Advisor
Advisor

May be some indirect workaround for this?

PS: OLE is very confusing not only for API user even don't see it in the browser...

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 6 of 6

Maxim-CADman77
Advisor
Advisor
Accepted solution

Haven't invented nothing smarter then let as many empty sheets as OLE-objects are inserted to IDW.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes