Read summary information from file using SOLIDWORKS API
This VBA macro extracts the data from the Summary Information tab from custom properties of the active SOLIDWORKS document using SOLIDWORKS API. This information includes author, keywords, comments, title, creation info, last saved info.
Result is output to the immediate window of VBA editor in the following format:
Author: CodeStack Keywords: sample,summary,api Comments: Example comments Title: Summary API Example Subject: CodeStack API Examples Created: Tuesday, 10 September 2019 10:35:37 AM Last Saved: Tuesday, 10 September 2019 11:08:23 AM Last Saved By: artem.taturevych Last Saved With: SOLIDWORKS 2019
Dim swApp As SldWorks.SldWorks Sub main() Set swApp = Application.SldWorks Dim swModel As SldWorks.ModelDoc2 Set swModel = swApp.ActiveDoc If Not swModel Is Nothing Then Debug.Print "Author: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoAuthor) Debug.Print "Keywords: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoKeywords) Debug.Print "Comments: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoComment) Debug.Print "Title: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoTitle) Debug.Print "Subject: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoSubject) Debug.Print "Created: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoCreateDate2) Debug.Print "Last Saved: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoSaveDate2) Debug.Print "Last Saved By: " & swModel.SummaryInfo(swSummInfoField_e.swSumInfoSavedBy) Debug.Print "Last Saved With: " & GetLastSavedWith(swModel) Else MsgBox "Please open model" End If End Sub Function GetLastSavedWith(model As SldWorks.ModelDoc2) As String Dim vHistory As Variant vHistory = model.VersionHistory() Dim vers As String vers = vHistory(UBound(vHistory)) vers = Mid(vers, InStr(vers, "[") + 1, 4) GetLastSavedWith = "SOLIDWORKS " & vers End Function