Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
AlexFielder
2993 Views, 13 Replies

iLogic Insert OLE Object problem

Hi All,

 

I have the following piece of iLogic cobbled together from various sources:

 

Dim doc as Document
doc = ThisApplication.ActiveDocument

'Verify the current document has been saved.
If doc.FullFileName = "" Then
	MessageBox.Show("This document must be saved first.")
	Exit Sub
End If

Dim selectedfile As String = String.Empty
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Dwg files (*.dwg)|*.dwg|Excel files (*.xlsx)|*.xlsx|pdf files (*.pdf)|*.pdf|Inventor parts (*.ipt)|*.ipt"
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
oFileDlg.MultiSelectEnabled = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End If

MessageBox.Show("You selected: " & selectedfile , "iLogic")
Dim oleReference As ReferencedOLEFileDescriptor
If selectedfile.Contains("|") Then ' we have multiple files selected.
	Dim file As String() = selectedfile.Split("|")
	For Each s as String in file
		MessageBox.Show("You selected: " & s , "iLogic")
		oleReference = doc.ReferencedOLEFileDescriptors.Add(s,kOLEDocumentLinkObject)
		oleReference.BrowserVisible = True
		oleReference.Visible = false
		oleReference.DisplayName = Mid$(s, InStrRev(s, "\") + 1)
	Next
Else
	oleReference = doc.ReferencedOLEFileDescriptors.Add(selectedFile,kOLEDocumentLinkObject)
	oleReference.BrowserVisible = True
	oleReference.Visible = false
	oleReference.DisplayName = Mid$(selectedFile, InStrRev(selectedFile, "\") + 1)
End If

 It works fine except that the resultant "3rd Party" folder contains icons with this image:

 

notepad.PNG

Instead of the image created when you manually click the "Insert Object" button on the Manage Ribbon -> Insert tab:

 

normal.PNG

 

Am I missing something which means that iLogic-inserted olereferences aren't treated the same as manually input ones?

 

Also, when I do this manually, the files are added to Vault Pro 2014 as "children" of whichever file I have run the iLogic within.

 

Thanks in advance,

 

Alex.