Macro to extract Configuration Properties to a TXT file

Hello,

 

I'm trying to extract some Part properties to a TXT file to pass them onto another software (some are additional properties ad-hoc created).
When I try to access them via VBA I get always the same error

 

ByRef argument type incompatible

 

Does anybody have a clue?

 

I attached the macro for reference, in BOLD where I usually get the error.

Thanks!

Option Explicit

Sub main()
    ' Connect to SolidWorks using late binding for the Custom Property Manager.
    Dim swApp As Object
    Set swApp = Application.SldWorks

    ' Get the active document (part, assembly, or drawing)
    Dim swModel As Object
    Set swModel = swApp.ActiveDoc
    If swModel Is Nothing Then
        MsgBox "No active document open. Please open a part, assembly, or drawing and try again.", _
               vbExclamation, "Error"
        Exit Sub
    End If

    ' Get the active configuration name (since these are configuration properties).
    Dim configName As String
    configName = swModel.ConfigurationManager.ActiveConfiguration.Name

    ' Obtain the Custom Property Manager for the active configuration using late binding.
    Dim cusPropMgr As Object
    Set cusPropMgr = swModel.Extension.CustomPropertyManager(configName)

    ' Define the list of property names to extract.
    Dim propNames As Variant
    propNames = Array("ArtikelNr", "Description_DE", "Description_EN", "Typ", _
                      "Material", "AC-Code", "DWG", "Gewicht")

    ' Build the output string with semicolons as delimiters.
    Dim outputStr As String
    outputStr = ""

    Dim i As Integer
    Dim currentPropName As String
    Dim tempVal As String
    Dim retVal As Long
    
    ' Declare useCached as a Variant and set it to False.
    ' (Late binding should bypass the compile-time type check.)
    Dim useCached As Variant
    useCached = False

    For i = LBound(propNames) To UBound(propNames)
        currentPropName = propNames(i)
        tempVal = ""
        
        ' Call Get2. With late binding, the parameter type check is deferred.

        retVal = cusPropMgr.Get2(currentPropName, useCached, tempVal)
        
        ' If the property is empty or not found, substitute a single space.
        If Trim(tempVal) = "" Then
            tempVal = " "
        End If
        
        outputStr = outputStr & tempVal & ";"
    Next i

    ' Define the file path for the text output.
    Dim filePath As String
    filePath = "C:\temp\sw_custom_props.txt"
    
    ' Write the output string to the file.
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim txtFile As Object
    Set txtFile = fso.CreateTextFile(filePath, True)
    txtFile.WriteLine outputStr
    txtFile.Close

    MsgBox "Properties exported successfully to:" & vbCrLf & filePath, vbInformation, "Export Complete"
End Sub