Get file type of embedded files

Get file type of embedded files

harvey_craig2RCUH
Advocate Advocate
7,611 Views
4 Replies
Message 1 of 5

Get file type of embedded files

harvey_craig2RCUH
Advocate
Advocate

I have two file embedded on my drawing. A jpeg and spreadsheet:

harvey_craig2RCUH_0-1734346666394.png

I am trying to write a rule that loops through the 3rd party items and deletes if it its a spreadsheet:

Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument
Dim ref As Inventor.ReferencedOLEFileDescriptor
For Each ref In oDoc.ReferencedOLEFileDescriptors
	MsgBox(ref.DisplayName)
	If ref.DisplayName.EndsWith(".xlsx") Then
		ref.Delete 'delete reference
	End If
Next

This is wrong because the DisplayName returns "Embedding 5" etc. How can I differentiate between the file types? I have looked through every option in Intellisense and they both file types give the same result for each.

harvey_craig2RCUH_1-1734346896957.png

harvey_craig2RCUH_2-1734346929193.png

 

Thanks,

Harvey

 

0 Likes
Accepted solutions (1)
7,612 Views
4 Replies
Replies (4)
Message 2 of 5

marcin_otręba
Advisor
Advisor

use .fullfilename instead displayname.

You can also check:

 

marcin_otrba_0-1734348169084.png

 

 

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 5

harvey_craig2RCUH
Advocate
Advocate

The .fullfilename returns an empty string, I'm assuming because it's embedded rather than linked. 

 

It's not a  fileDescriptor Object it's a ReferencedOLEFileDescriptor Object. From there you can access the fileDescriptor object but the options in there that are not included in the ReferencedOLEFileDescriptor don't work and returns a 'Object reference not set to an instance of an object.' error.

 

Thanks for having a look at it,

Cheers,

Harvey

0 Likes
Message 4 of 5

marcin_otręba
Advisor
Advisor
Accepted solution

sorry, i was checking it for linked olefiledescriptor, and in this situation it works. When i try with embedded olefiledescriptor it is empty as you wrote.

marcin_otrba_0-1734352988595.png

 

 

in this situation for omit this problem in future there is workaround to name it when you add it trough code like:

 

.DisplayName = "xlsembededfile"

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 5

harvey_craig2RCUH
Advocate
Advocate

Perfect, that works great!

0 Likes