Hi, everyone,
Can someone tell me where is the mistake in following code:
Public Sub TestSelection()
Dim InvDoc As Document
Set InvDoc = ThisApplication.ActiveDocument
Dim oPartDoc As PartDocument
Set oPartDoc = InvDoc.ReferencedDocuments(1)
Call oPartDoc.Activate
End Sub
I have an assembly with two parts inside. I want to activate first of them (like Edit command in browser), but I got message "Method 'Activate' of object 'PartDocument' failed".
Solved! Go to Solution.
Solved by prakasht66. Go to Solution.
Hi,
I hope this will be help you out.
Public Sub TestSelection()
Dim InvDoc As Document
Set InvDoc = ThisApplication.ActiveDocument
If InvDoc.DocumentType = kAssemblyDocumentObject Then
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = ThisApplication.ActiveDocument
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAssyDoc.AllReferencedDocuments
For tt = 1 To oRefDocs.Count
Dim oDoc As Document
Set oDoc = oRefDocs.Item(tt)
If oDoc.DocumentType = kPartDocumentObject Then
Dim oOccEnum As ComponentOccurrencesEnumerator
Set oOccEnum = oAssyDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc)
Dim oOcc As ComponentOccurrence
Set oOcc = oOccEnum.Item(1)
Call oOcc.Edit
End If
Next tt
End If
End Sub