Public Sub OpenIDW() ' Angewendet in .ipt oder .iam wird die dazugehörige .idw geöffnet. ' Angewendet in .idw wird die dazugehörige .ipt oder .iam geöffnet. Dim oDoc As Document Dim oReferencedDoc As Document Dim oDocName As String Dim oReferencedDocName As String Dim Dateiname As String Dim ReferencedDateiname As String Dim fs As Object If ThisApplication.ActiveDocumentType = kPartDocumentObject Then Set oDoc = ThisApplication.ActiveDocument End If If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then Set oDoc = ThisApplication.ActiveDocument End If If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then Dim oAssemDoc As AssemblyDocument Set oAssemDoc = ThisApplication.ActiveDocument If oAssemDoc.ComponentDefinition.ActiveOccurrence Is Nothing Then 'keine Occurance aktiv (IAM direkt geöffnet) Set oDoc = ThisApplication.ActiveDocument Else 'Occurance aktiv (In-Place geöffnet) Set oDoc = ThisApplication.ActiveEditObject End If End If 'DocumentType = kAssemblyDocumentObject 'Set oDoc = ThisApplication.ActiveDocument If TypeOf oDoc Is DrawingDocument Then 'Offenes Dokument ist eine Zeichnung Set oReferencedDoc = oDoc.ReferencedDocuments.Item(1) 'Debug.Print "Handle vom Referenzierten Dokument " & oReferencedDoc & " Dateiname: " & oReferencedDoc.FullFileName ThisApplication.Documents.Open (oReferencedDoc.FullFileName) Exit Sub End If oDocName = oDoc.FullFileName If oDocName = "" Then MsgBox "Bitte Modell erst speichern!" Exit Sub End If Dateiname = Left(oDoc.FullFileName, Len(oDoc.FullFileName) - 4) & ".idw" Set fs = CreateObject("Scripting.FileSystemObject") If fs.FileExists(Dateiname) = True Then ThisApplication.Documents.Open (Dateiname) Else 'MsgBox "keine IDW vorhanden" 'Dim Msg As String 'Dim title As String 'title = "Jetzt kommt der wieder mit Z ... !" 'Titelzeie für MsgBox 'Msg = "Mach erstmal eine IDW... " + Chr(13) & Chr(10) + Chr(13) & Chr(10) + "oder klau sie irgendwo ;-)" 'MsgBox Msg, 0, title Dim byWert As Byte byWert = MsgBox("IDW erstellen? JA / NEIN", vbYesNoCancel, "IDW nicht vorhanden") If (byWert = vbCancel) Or (byWert = vbNo) Then Exit Sub If byWert = vbYes Then 'JA = neue IDW 'neue IDW aus Vorlage erstellen Dim sTemplate As String sTemplate = ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath & "Norm_RD.idw" Dim oNewDrawDoc As DrawingDocument Set oNewDrawDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sTemplate) Dim oSheet As Sheet Set oSheet = oNewDrawDoc.ActiveSheet End If 'byWert = vbNo End If 'fs.FileExists(Dateiname) End Sub 'OpenIDW