Ich habe folgenden Beispiel-Code gefunden:
Sub main()
Set swApp = Application.SldWorks
' Open assembly
openFile = "c:\TEST\Baugruppe1.sldasm"
Set swModelDoc = swApp.OpenDoc6(openFile, swDocASSEMBLY, swOpenDocOptions_Silent, "", errors, warnings)
Set swModelDocExt = swModelDoc.Extension
' Get Pack and Go object
Debug.Print "Pack and Go"
Set swPackAndGo = swModelDocExt.GetPackAndGo
' Get number of documents in assembly
namesCount = swPackAndGo.GetDocumentNamesCount
Debug.Print " Number of model documents: " & namesCount
' Include any drawings and simulation results
swPackAndGo.IncludeDrawings = True
Debug.Print " Include drawings: " & swPackAndGo.IncludeDrawings
swPackAndGo.IncludeSimulationResults = True
Debug.Print " Include simulation results: " & swPackAndGo.IncludeSimulationResults
' Get current paths and filenames of the assembly's documents
status = swPackAndGo.GetDocumentNames(pgFileNames)
Debug.Print ""
Debug.Print " Current path and filenames: "
If (Not (IsEmpty(pgFileNames))) Then
For i = 0 To UBound(pgFileNames)
pgFileNames(i) = StrConv(pgFileNames(i), vbUpperCase)
Debug.Print " The path and filename is: " & pgFileNames(i)
Next i
End If
' Get current save-to paths and filenames of the assembly's documents
status = swPackAndGo.GetDocumentSaveToNames(pgFileNames, pgFileStatus)
Debug.Print ""
Debug.Print " Current default save-to filenames: "
If (Not (IsEmpty(pgFileNames))) Then
For i = 0 To UBound(pgFileNames)
Debug.Print " The path and filename is: " & pgFileNames(i)
Next i
End If
' Folder where to save the files
myPath = "c:\TEST\PNG\"
' Create your own filenames for the model's documents
ReDim pgSetFileNames(namesCount - 1)
Debug.Print ""
Debug.Print " My Pack and Go path and filenames before adding prefix and suffix: "
j = 0
For i = 0 To (namesCount - 1)
myFileName = pgFileNames(i)
Debug.Print myFileName
Debug.Print InStr(LCase(myFileName), LCase("gemeinsame"))
If InStr(LCase(myFileName), LCase("gemeinsame")) = 0 Then
' Determine type of SolidWorks file based on file extension
If InStr(LCase(myFileName), "sldprt") > 0 Or InStr(LCase(myFileName), "sldasm") > 0 Or InStr(LCase(myFileName), "slddrw") > 0 Then
myFileName = j & Right(myFileName, 7)
Else
Exit Sub
End If
If myFileName = "" Then pgSetFileNames(i) = "" Else pgSetFileNames(i) = myPath & myFileName
Debug.Print " My path and filename is: " & pgSetFileNames(i)
j = j + 1
Debug.Print pgSetFileNames(i)
End If
Next i
Debug.Print "Siehst du ist leer: " & pgSetFileNames(3)
' Ensure that any copied drawing references the correct copied part
status = swPackAndGo.SetSaveToName(True, myPath)
' Set document paths and names for Pack and Go
status = swPackAndGo.SetDocumentSaveToNames(pgSetFileNames)
' Verify document paths and filenames after adding prefix and suffix
ReDim pgGetFileNames(namesCount - 1)
ReDim pgDocumentStatus(namesCount - 1)
status = swPackAndGo.GetDocumentSaveToNames(pgGetFileNames, pgDocumentStatus)
Debug.Print ""
Debug.Print " My Pack and Go path and filenames after adding prefix and suffix: "
For i = 0 To (namesCount - 1)
Debug.Print " My path and filename is: " & pgGetFileNames(i)
Next i
' Pack and Go
statuses = swModelDocExt.SavePackAndGo(swPackAndGo)
End Sub
Die Baugruppe1 besteht aus 3 Teilen, 2 davon sind im gleichen Pfad und sollen beim Pack and Go auch mit kopiert werden. Das 3.Teil ist aus unserem selbst erstellten Teile-Archiv, der Pfad beinhaltet das Wort "Vorlage". Ich müsste jetzt also wissen wo in dem Code ich ihm sagen kann "alle Dateien mit dem String "Vorlage" NICHT mit kopieren"
Wenn du oder auch gerne jemand anderes mir das verraten kann könnte ich ruhigen Gewissens in meinen Urlaub fahren
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP