Type Anweisung

In diesem Stream erkläre ich die Type Anweisung.

Und an dieser Stelle der Code der im Makro vorhanden ist.

Option Explicit

Type DateiInfos
    Name As String
    Typ As swDocumentTypes_e
    Pfad As String
    ModelDoc As ModelDoc2
End Type

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim Daten() As DateiInfos
Dim openDocsCount As Long
Dim openDocs As Variant
Dim i As Long
Dim openDoc As Variant

Sub main()
    Set swApp = Application.SldWorks
    openDocs = swApp.GetDocuments
    openDocsCount = swApp.GetDocumentCount
    ReDim Daten(openDocsCount - 1)
    i = 0
    For Each openDoc In openDocs
        Set Daten(i).ModelDoc = openDoc
        Daten(i).Pfad = Daten(i).ModelDoc.GetPathName
        Daten(i).Typ = Daten(i).ModelDoc.GetType
        i = i + 1
    Next
    
    For i = 0 To UBound(Daten)
        If Daten(i).Typ = swDocDRAWING Then
            Debug.Print "gefunden!"
        End If
    Next
End Sub

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert