Hallo Felix,
dann war bei deinem Versuch der Inventor nicht gestartet...
Hier mal ein Beispiel wie es gehen kann (der Form1 wurde noch ein Button1 hinzugefügt!)
Imports Inventor
Public Class Form1
Public ThisApplication As Inventor.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DN As String
Dim oDoc As Inventor.Document
'Ist ein Dokument geöffnet?
oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
'Nein, dann ist hier schluss
MsgBox("Kein Dokument geöffnet")
Exit Sub
End If
Try
Dim opropsets As Inventor.PropertySets
Dim odtPropertySet As Inventor.PropertySet
opropsets = oDoc.PropertySets
odtPropertySet = opropsets.Item("Inventor User Defined Properties")
DN = odtPropertySet.Item("DN").Value
TextBox1.Text = DN
Catch ex As Exception
MsgBox("Fehler: " & Err.Description)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
'Hallo? Inventor?
ThisApplication = GetObject(, "Inventor.Application")
Catch
'Nicht da, also neues Objekt erzeugen
ThisApplication = CreateObject("Inventor.Application")
End Try
If ThisApplication Is Nothing Then
'Inventor konnte nicht gefunden werden
MsgBox("Kein Inventor vorhanden")
End
End If
ThisApplication.Visible = True
End Sub
End Class
Gruß
Stefan
------------------
Wer nicht mitmacht, kann auch nichts verändern
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP