Option Explicit Public Sub Auswahl_Standardansicht() Dim invDoc As Document Set invDoc = thisapplication.ActiveDocument Dim openDoc As AssemblyDocument Dim oBOM As BOM Dim odoc As Document Dim oBOMRow As BOMRow Dim AssemblyDef As AssemblyComponentDefinition Dim repManager As RepresentationsManager Dim viewrep As DesignViewRepresentations Dim rep As DesignViewRepresentation Dim activdoc As AssemblyDocument 'Abbruch wenn keine Baugruppe geöffnet ist If thisapplication.Documents.Count = 0 Then MsgBox "Keine Dokumente geöffnet. Es muss eine Baugruppe geöffnet sein." Exit Sub End If If thisapplication.ActiveDocumentType <> kAssemblyDocumentObject Then MsgBox "Das geöffnete Dokument ist keine Baugruppe. Es muss eine Baugruppe geöffnet sein." Exit Sub End If Set openDoc = invDoc Set oBOM = openDoc.ComponentDefinition.BOM If oBOM.StructuredViewEnabled = False Then oBOM.StructuredViewEnabled = True End If Set AssemblyDef = openDoc.ComponentDefinition Set repManager = AssemblyDef.RepresentationsManager Set viewrep = repManager.DesignViewRepresentations Set rep = viewrep.Item("Standard") rep.Activate For Each oBOMRow In oBOM.BOMViews.Item("Strukturiert").BOMRows Set odoc = oBOMRow.ComponentDefinitions.Item(1).Document If odoc.DocumentType = kAssemblyDocumentObject And oBOMRow.BOMStructure <> kPurchasedBOMStructure And oBOMRow.BOMStructure <> kPhantomBOMStructure Then Set AssemblyDef = odoc.ComponentDefinition Set repManager = AssemblyDef.RepresentationsManager Set viewrep = repManager.DesignViewRepresentations Set rep = viewrep.Item("Standard") rep.Activate 'MsgBox odoc.DisplayName End If Next For Each invDoc In invDoc.AllReferencedDocuments If invDoc.DocumentType = kAssemblyDocumentObject Then Set openDoc = invDoc Set oBOM = openDoc.ComponentDefinition.BOM If oBOM.StructuredViewEnabled = False Then On Error Resume Next oBOM.StructuredViewEnabled = True End If For Each oBOMRow In oBOM.BOMViews.Item("Strukturiert").BOMRows Set odoc = oBOMRow.ComponentDefinitions.Item(1).Document If odoc.DocumentType = kAssemblyDocumentObject And oBOMRow.BOMStructure <> kPurchasedBOMStructure And oBOMRow.BOMStructure <> kPhantomBOMStructure Then Set AssemblyDef = odoc.ComponentDefinition Set repManager = AssemblyDef.RepresentationsManager Set viewrep = repManager.DesignViewRepresentations Set rep = viewrep.Item("Standard") rep.Activate End If Next End If Next End Sub