Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Would anyone mind sending me in the correct direction here? Attempting to make a sub to check for Ole files. The commented lines at the bottom work just fine but trying to use a For statement to simplify (lines at the top). On line 4, if the OLEFileDescriptors.Count > 0, I am getting an exception. I suspect it has something to do with the "oleFile" type but I'm lost.
Thank you!
Private Sub checkOle(doc As Inventor.ApprenticeServerDocument)
'Check for 3rd party references
Debug.Print(doc.DisplayName & ": " & doc.ReferencedOLEFileDescriptors.Count)
For Each oleFile As Inventor.ApprenticeServerDocument In doc.ReferencedOLEFileDescriptors
If Not oleFile Is Nothing Then
'Handle embedded objects (They don't copy very well)
If Not oleFile.StartsWith("Embedding") Then
'Add the file to the listbox
listboxFileView.Items.Add(oleFile)
End If
End If
Next
'The code below is what I have been using and it works fine but trying to simplify...
'Dim oleCount As Integer = doc.ReferencedOLEFileDescriptors.Count
'If oleCount > 0 Then
' Dim z As Integer = 0
' For z = 1 To oleCount
' Dim tpDoc As String = doc.ReferencedOLEFileDescriptors.Item(z).FullFileName
' 'Added 8-1-11 to handle corrupt? files that had embedded spread sheets
' If Not tpDoc = Nothing Then
' 'Handle embedded objects (They don't copy very well)
' If Not tpDoc.StartsWith("Embedding") Then
' 'Add the file to the listbox
' listboxFileView.Items.Add(tpDoc)
' End If
' End If
' Next
'End If
End Sub
Solved! Go to Solution.