Frage: Die Dateien sollen nicht über einen temporären Ordner gepackt werden, sondern direkt. Noch einmal zur Erinnerung: Eine Installation von 7Zip ist nicht notwendig.
Man kann mit dem Kommandozeilentool arbeiten. Was mit dem Kommandozeilentool "7za.exe" erreicht werden kann, klappt auch auf eine andere Weise: Entweder installieren Sie 7Zip auf einer virtuellen Maschine, oder Sie nutzen den Windows Installer zum Auspacken der MSI-Datei. Nehmen wir an die Datei "7z922.msi" befindet sich in "C:\Temp\7z". Dort ist noch ein Unterordner mit Namen "7". Mit folgendem Befehl auf der Dos-Ebene entpacken Sie den Inhalt der MSI-Datei: "msiexec /a 7z922.msi /qb targetdir=C:\Temp\7z\7".
Suchen Sie dann nach den beiden Dateien "7z.exe und 7z.dll". Diese beiden können Sie nun auch als Kommandozeilentool nutzen. Dies gilt dann auch analog für Windows 64 Bit mit der Datei "7z922-x64.msi".
The files should not be packed on a temporary folder, but directly. Just to remind: An installation of 7Zip is not necessary.
You can use the command line tool. What can be achieved with the command line tool "7za.exe" works well in a different way: either install 7zip on a virtual machine, or use the Windows Installer to unpack the MSI file. Suppose the file "7z922.msi" is located in "C: \ Temp \ 7z". There is still a subfolder named "7". With the following command at the DOS level, you extract the contents of the MSI file: "msiexec /a 7z922.msi /qb targetdir=C:\Temp\7z\7".
Try searching for the two files "7z.exe and 7z.dll". These two you can now use it as a command line tool. This applies analogously also for Windows 64 bit with the file "7z922-x64.msi".
Hier noch eine Beispieldatei / Here's a sample file:
ZIP - mit 7Zip bestimmte Dateien eines Ordners mit Passwort packen - Update...[ZIP 4 MB]
Link:
7Zip...
7Zip - Download...
Command-Line Options - Msiexec.exe
Man kann mit dem Kommandozeilentool arbeiten. Was mit dem Kommandozeilentool "7za.exe" erreicht werden kann, klappt auch auf eine andere Weise: Entweder installieren Sie 7Zip auf einer virtuellen Maschine, oder Sie nutzen den Windows Installer zum Auspacken der MSI-Datei. Nehmen wir an die Datei "7z922.msi" befindet sich in "C:\Temp\7z". Dort ist noch ein Unterordner mit Namen "7". Mit folgendem Befehl auf der Dos-Ebene entpacken Sie den Inhalt der MSI-Datei: "msiexec /a 7z922.msi /qb targetdir=C:\Temp\7z\7".
Suchen Sie dann nach den beiden Dateien "7z.exe und 7z.dll". Diese beiden können Sie nun auch als Kommandozeilentool nutzen. Dies gilt dann auch analog für Windows 64 Bit mit der Datei "7z922-x64.msi".
The files should not be packed on a temporary folder, but directly. Just to remind: An installation of 7Zip is not necessary.
You can use the command line tool. What can be achieved with the command line tool "7za.exe" works well in a different way: either install 7zip on a virtual machine, or use the Windows Installer to unpack the MSI file. Suppose the file "7z922.msi" is located in "C: \ Temp \ 7z". There is still a subfolder named "7". With the following command at the DOS level, you extract the contents of the MSI file: "msiexec /a 7z922.msi /qb targetdir=C:\Temp\7z\7".
Try searching for the two files "7z.exe and 7z.dll". These two you can now use it as a command line tool. This applies analogously also for Windows 64 bit with the file "7z922-x64.msi".
Hier noch eine Beispieldatei / Here's a sample file:
ZIP - mit 7Zip bestimmte Dateien eines Ordners mit Passwort packen - Update...[ZIP 4 MB]
Link:
7Zip...
7Zip - Download...
Command-Line Options - Msiexec.exe
OptionExplicit
' Konstante für die KONSOLENANWENDUNG 7Zip
' Keine Installation erforderlich
' Pfad ANPASSEN!!!!!!!!
ConststrZipAsString="C:\Temp\Zip\7za.exe"
'--------------------------------------------------------------------------
' Module : Modul1
' Author : Case (Ralf Stolzenburg)
' Date : 24.08.2013
' Purpose : 7-Zip alle Dateien eines Ordners packen als 7z...
'--------------------------------------------------------------------------
PublicSubMain()
DimlngLastRowAsLong
DimstrPathQAsString
DimstrPathZAsString
DimstrTMPAsString
DimstrArgAsString
OnErrorGoToFin
' Der Code bezieht sich auf ein bestimmtes Objekt
' Hier Tabelle1 = der CodeName der Tabelle
' Im VBA-Editor der Name VOR der Klammer - Tabelle1 (Tabelle1)
' im englischen Excel in der Regel Sheet1
' Alles was sich auf dieses "With" bezieht
' MUSS mit einem Punkt beginnen
WithTabelle1
' Letzte Zeile in Spalte B
lngLastRow=IIf(IsEmpty(.Cells(.Rows.Count,2)),_
.Cells(.Rows.Count,2).End(xlUp).Row,.Rows.Count)
' Pfad in dem die zu packenden Dateien sind
strPathQ=.Range("A1").Text
' Backslash anhängen, wenn nicht vorhanden
strPathQ=IIf(Right(strPathQ,1)<>"\",strPathQ&"\",strPathQ)
' Pfad in den die gepackte 7z-Datei kommt
strPathZ=.Range("C1").Text
' Backslash anhängen, wenn nicht vorhanden
strPathZ=IIf(Right(strPathZ,1)<>"\",strPathZ&"\",strPathZ)
' Schleife über alle Einträge in Spalte B
ForlngLastRow=1TolngLastRow
' Sammeln der Dateinamen inklusive Pfad und Leereichen am Schluss
strTMP=strTMP&strPathQ&.Cells(lngLastRow,2).Text&" "
NextlngLastRow
' Letztes Leerzeichen entfernen
strTMP=Left(strTMP,Len(strTMP)-1)
' Packt die Dateien der Variablen "strTMP" als 7z-Datei
' Zielordner "strPathZ" mit Passwort "passwort"
strArg=strZip&" a -ppasswort "&strPathZ&"Zip.7z "&strTMP
ShellAndWaitstrArg
EndWith
Fin:
' Wenn die Fehlernummer NICHT 0 ist, dann gib die Fehlernummer
' und die Fehlerbeschreibung aus
IfErr.Number<>0ThenMsgBox"Fehler: "&_
Err.Number&" "&Err.Description
EndSub
'--------------------------------------------------------------------------
' Module : Modul1
' Procedure : ShellAndWait
' Author : Case (Ralf Stolzenburg)
' Date : 24.08.2013
' Purpose : ShellAndWait mit ausgeblendetem Dosfenster...
'--------------------------------------------------------------------------
PrivateSubShellAndWait(ByValstrPathNameAsString)
DimWshShellAsObject
OnErrorGoToFin
SetWshShell=CreateObject("WScript.Shell")
WshShell.RunstrPathName,0,True
Fin:
SetWshShell=Nothing
IfErr.Number<>0ThenMsgBox"Error: "&_
Err.Number&" "&Err.Description
EndSub