I do have code this code to remove ole links but it works on part level.
1. Is it possible to run this code from assembly and remove ole links from each part.
Some images with no reason knowing to me att. to each part in my assembly and can't check in vault. Shouldn't be tool for easy removal, and not to go part by part waste a lot time for nothing.
2. What make this situation?
Please experts I need help ASAP. This happened and it just pain.
Thank you All.
Solved! Go to Solution.
Solved by MechMachineMan. Go to Solution.
The following code makes the OLE links visible in the browser, so that you can easily delete the through the UI.
Sub Main() Dim oDoc As Document oDoc = ThisApplication.ActiveDocument If oDoc.ReferencedOLEFileDescriptors.Count > 0 For Each oOLEFileRef In oDoc.ReferencedOLEFileDescriptors oOLEFileRef.BrowserVisible = True Next End If End Sub
Can this code be adjusted to run from assembly?
Public Sub DeleteOLEReference()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc.ReferencedOLEFileDescriptors.Count = 0 Then
MsgBox "There aren't any OLE references in this document."
Exit Sub
End If
Dim aOLERefs() As ReferencedOLEFileDescriptor
ReDim aOLERefs(oDoc.ReferencedOLEFileDescriptors.Count - 1)
Dim iRefCount As Integer
iRefCount = oDoc.ReferencedOLEFileDescriptors.Count
Dim i As Integer
For i = 1 To iRefCount
Set aOLERefs(i - 1) = oDoc.ReferencedOLEFileDescriptors.Item(i)
Next
For i = 1 To iRefCount
If MsgBox("Delete """ & aOLERefs(i - 1).FullFileName & """?", vbQuestion + vbYesNo) = vbYes Then
aOLERefs(i - 1).Delete
End If
Next
End Sub
1. Please properly nest code and use the code wrapper, so it's easier to read and copy.
2. That code works of the active document as it is, so it works on assembly, parts, drawings. If by "work from assembly" you mean have it traverse through all of the parts and sub-assemblies of that main assembly, then yes, this is also possible as well.
Sub Main() Dim oDoc As Document 'vba: Set oDoc = ThisApplication.ActiveDocument 'vb.net: 'oDoc = ThisDoc.Document Dim oLog As String For Each oSubDoc in oDoc.AllReferencedDocuments If oSubDoc.IsModifiable = True Then Call RemoveOLEsFromDoc(oSubDoc, oLog) End if Next Call MsgBox("Rule Complete!" & vblf & vblf & _ "OLEs Removed From: " & vblf & oLog) End Sub Sub RemoveOLEsFromDoc(ByVal oDoc As Document, ByRef oLogStr As String) If oDoc.ReferencedOLEFileDescriptors.Count > 0 For Each oOLEFileRef In oDoc.ReferencedOLEFileDescriptors 'oOLEFileRef.BrowserVisible = True oOLEFileRef.Delete Next oLogStr = oLogStr & oDoc.DisplayName End If End Sub
Cool thanks a lot. I run in assembly and remove all of them.
Thanks again
Can't find what you're looking for? Ask the community or share your knowledge.