Hallo,
ich setze hier mal einen etwas längeren Text rein, der das Setzen und Auslesen der Dokumenteninfo relevanten Felder zeigt. Ist vielleicht von allgemeinem Interesse. Die Prozedur infos_read zeigt die Informationen in Msgboxen an.
' Beispiel zum Auslesen der benutzerdefinierten Eigenschaft "Deutsche_Bezeichnung"
' in die Variable D_B
Dim swApp As Object
Dim Modeldoc As Object
Dim D_B as String
Const swSumInfoSubject = 1
Const swSumInfoAuthor = 2
Const swSumInfoKeywords = 3
Const swSumInfoComment = 4
Const swSumInfoSavedBy = 5
Const swSumInfoCreateDate = 6
Const swSumInfoSaveDate = 7
sub Feldauslesen_D_B()
Set swApp = CreateObject("SldWorks.Application")
set modeldoc= swapp.activedoc
D_B = Modeldoc.CustomInfo2("", "Deutsche_Bezeichnung")
msgbox D_B
end sub
Function Titel_read() 'liest Titel aus
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Titel_read = "" & Modeldoc.SummaryInfo(swSumInfoTitle)
'MsgBox Titel
End Function
Function Titel_set(Titel) 'setzt Titel
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Modeldoc.SummaryInfo(swSumInfoTitle) = Titel
'MsgBox Titel
End Function
Function Autor_read() 'liest Autor aus
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Autor_read = Modeldoc.SummaryInfo(swSumInfoAuthor)
'MsgBox Autor
End Function
Function Autor_set(Autor) 'setzt Autor
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Modeldoc.SummaryInfo(swSumInfoAuthor) = Autor
'MsgBox Autor
End Function
Function Stichworte_set(Stichworte) 'setzt Stichworte(String)
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Modeldoc.SummaryInfo(swSumInfoKeywords) = Stichworte
'MsgBox Stichworte
End Function
Function Stichworte_read() 'liest Stichworte aus
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Stichworte_read = Modeldoc.SummaryInfo(swSumInfoKeywords)
'MsgBox Stichworte
End Function
Function Anmerkung_set(Anmerkung) 'setzt Anmerkung(String)
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Anmerkung_set = Modeldoc.SummaryInfo(swSumInfoComment)
'MsgBox Kommentar_set
End Function
Function Anmerkung_read()
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Anmerkung_read = Modeldoc.SummaryInfo(swSumInfoComment)
'MsgBox Anmerkung
End Function
Function gespeichert_von_read()
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
gespeichert_von_read = Modeldoc.SummaryInfo(swSumInfoSavedBy)
'MsgBox gespeichert_von
End Function
Function Erstelldatum_und_Zeit_read()
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Erstelldatum_und_Zeit_read = Modeldoc.SummaryInfo(swSumInfoCreateDate)
'MsgBox Erstelldatum_und_Zeit
End Function
Function Speicherdatum_und_Zeit_read()
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
Speicherdatum_und_Zeit_read = Modeldoc.SummaryInfo(swSumInfoSaveDate)
'MsgBox Speicherdatum_und_Zeit
End Function
sub infos_read()
'Hilfsfunktion zur Anzeige der Informationen über das aktuelle Solidworks-Datei-Objekt
Set swApp = CreateObject("SldWorks.Application")
Set Modeldoc = swApp.ActiveDoc
MsgBox ((" Titel ist " & Titel_read & Chr$(10) & _
" Autor war " & Autor_read & Chr$(10) & _
" Stichworte sind " & Stichworte_read & Chr$(10) & _
" Anmerkungen sind " & Anmerkung_read & Chr$(10) & _
" erstellt von: " & gespeichert_von_read & Chr$(10) & _
" erstellt: Datum und Zeit: " & Erstelldatum_und_Zeit_read & Chr$(10) & _
" letzte Speicherung Datum und Zeit: " & Speicherdatum_und_Zeit_read))
End Function
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP