VERSION 5.00 Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm1 Caption = "UserForm1" ClientHeight = 3225 ClientLeft = 45 ClientTop = 330 ClientWidth = 4710 OleObjectBlob = "UserForm1.frx":0000 StartUpPosition = 1 'Fenstermitte End Attribute VB_Name = "UserForm1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim Name_stp, An_nr As String Dim bName_stpDa, bAn_nrDa As Boolean Private Sub CommandButton1_Click() Dim oApp As Inventor.Application Set oApp = ThisApplication Dim oDoc As Document Set oDoc = oApp.ActiveDocument Dim oProp As Property Dim Filename As String Name_stp = UCase(TextBox1.Text) 'If Len(Name_stp) < 41 Then ' Do While Len(Name_stp) < 41 ' Name_stp = Name_stp & " " ' Loop 'End If An_nr = TextBox2.Text If bName_stpDa Then oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("Name_stp").Value = Name_stp Else oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Add Name_stp, "Name_stp" End If If bAn_nrDa Then oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("An_nr").Value = An_nr Else oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Add An_nr, "An_nr" End If If ThisApplication.ActiveDocumentType = kPartDocumentObject Then 'Bauteil Filename = Name_stp & An_nr & ".ipt" Else 'Baugruppe Filename = Name_stp & An_nr & ".iam" End If Call oDoc.SaveAs(Filename, False) End End Sub Private Sub CommandButton2_Click() End End Sub Private Sub UserForm_Initialize() Dim E As Integer Dim oDoc As Document Set oDoc = ThisApplication.ActiveDocument Dim oProp As Property bName_stpDa = False bAn_nrDa = False If ThisApplication.ActiveDocumentType = kPartDocumentObject Or ThisApplication.ActiveDocumentType = kPartAssemblyDocumentObject Then 'Bauteil oder Baugruppe For Each oProp In oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") 'Benutzerdefiniert If oProp.Name = "Name_stp" Then bName_stpDa = True Exit For End If Next For Each oProp In oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") 'Benutzerdefiniert If oProp.Name = "An_nr" Then bAn_nrDa = True Exit For End If Next If bName_stpDa Then Name_stp = oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("Name_stp").Value If Name_stp <> "" Then TextBox1.Text = Name_stp End If End If If bAn_nrDa Then An_nr = oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("An_nr").Value If An_nr <> "" Then TextBox2.Text = An_nr End If End If Else E = MsgBox("Fehler ! Kein Bauteil oder Baugruppe", vbCritical, "Fehler") End End If End Sub