Recover Properties

Hello everyone, I am looking to recover the " title " and " keywords " properties of my Solidworks files
I told myself that it was going to be simple with Power Query and presto.
and presto, it doesn't work


the idea was to retrieve these two properties of my solid files from a directory in an Excel table
it works in part, I can recover a lot of properties, but not this one while Windows shows them to me
via VBA, I looked too, but nothing convincing (besides, I'm not a VBA expert)
I don't have the visiativ tools either
Is it feasible? and by what means

Thank you

Hello

Unless I'm mistaken, it's not accessible via Windows APIs. You have to look at the document manager side in the Solidworks APIs

3 Likes

Okay, I'll look that way
it's a shame because Windows displays them well

Hello
@SOFAME, are you looking to have these properties in Excel from Solidworks or Windows (Excel)?

Let's say that I wanted to do it from Windows but obviously not feasible
so yes certainly from SolidWorks.

Attached is an example to inspire
Prerequisite
1, Open SW with all your documents you want to extract the info (an alternative to browse the folder and then open all the docs by VBA)
2, Open Excel file
3, Macro Stream
4, Fill in the reference " SOLIDWORKS 20** type/command/constant lib " in Tools >reference.
5, Inquire the right version of SW.

Option Explicit
Dim swapp As SldWorks.SldWorks
Dim swmodel As ModelDoc2

Sub test()
    Set swapp = GetObject("", "sldworks.application.26")    '2022   >   30
                                                            '2021   >   29
                                                            '2020   >   28
                                                            '...
    Dim row As Long
    row = 1
    Cells(row, 1).Value = "Title"
    Cells(row, 2).Value = "Author"
    Cells(row, 3).Value = "Key words"
        
    Set swmodel = swapp.GetFirstDocument
    While Not swmodel Is Nothing
        If swmodel.Visible Then
            row = row + 1
            Cells(row, 1).Value = swmodel.GetTitle()
            Cells(row, 2).Value = swmodel.SummaryInfo(swSumInfoAuthor)
            Cells(row, 3).Value = swmodel.SummaryInfo(swSumInfoKeywords)
        End If
        Set swmodel = swmodel.GetNext
    Wend
    
End Sub

Result
Capture_SUMMARYINFO

(if you want to include all the components (sub-assembly) of the assemblies, reference components, just remove the visibility condition, very convenient you open an assembly, and everything will be included in excel :wink:)

Of course the ideal would be to use docmanager if you have a key, it will be more optimal since it will be more necessary to open everything with sw,

Otherwise for a full excel version, I found This

Sub test2()
    Dim sfile As Variant
    Dim oshell As Object
    Dim odir As Object
    Set oshell = CreateObject("shell.application")
    Set odir = oshell.Namespace("C:\Users\dell\Desktop\test")
    
    Dim row As Long
    row = 1
    Cells(row, 1).Value = "Title"
    Cells(row, 2).Value = "Author"
    Cells(row, 3).Value = "Key words"

    For Each sfile In odir.Items
        'For i = 0 To 40
            'Debug.Print i & "   :    " & odir.getdetailsof(sfile, i)
        'Next
        row = row + 1
        Cells(row, 1).Value = odir.getdetailsof(sfile, 0)
        Cells(row, 2).Value = odir.getdetailsof(sfile, 20)
        Cells(row, 3).Value = odir.getdetailsof(sfile, 18)
    Next
End Sub

Simple and efficient (only the management of file types remains, or in case where the folder contains other files than solidworks) :wink:

Thank you for these answers, I will look into this and I will keep you informed

I may have misinterpreted the "title", apparently it's not gettitle() but rather summaryinfo(swsuminfotitle), for the 2nd example the clue on my windows 10 and 21 configuration