AW: zippen funzt net
26.07.2010 15:03:23
Tino
Hallo,
hab ich auch mal gebraucht.
'Zip Datei erstellen, Pfad Dos kompatibel*********************************************************
Private Declare Function GetShortPathNameA Lib "kernel32" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Public Function ShortPath(ByRef Path As String) As String
Dim n As Long
ShortPath = Space$(256)
n = GetShortPathNameA(Path, ShortPath, 255)
ShortPath = Left$(ShortPath, n)
End Function
Sub sb7z(Quelle$, Ziel$, ZipDateiName$, Optional sFilter$ = "*.*")
Dim lstr7zPfad$
'Pfad Dos kompatibel machen
Ziel = ShortPath(Ziel)
Quelle = ShortPath(Quelle)
'hier Verzeichnis eintragen, in dem 7Zip installiert ist
lstr7zPfad = "C:\Program Files\7-Zip\7z.exe a -tzip "
'komprimiert nur Dateien
Shell lstr7zPfad & Ziel$ & ZipDateiName$ & " " & Quelle$ & sFilter
End Sub
Sub Zippen()
Dim zipName As String, sQuelle As String, sZiel$
'wo die Dateien sind
sQuelle = "C:\Mein Ordner\"
'wo das Zip File hin soll
sZiel$ = IIf(Right$(ActiveWorkbook.Path, 1) = "\", ActiveWorkbook.Path, ActiveWorkbook.Path & "\")
'Zip Datei Name
zipName = "MeinZipFile.zip"
'Parameter: Quelle, Ziel ,Zip-Name, [Filter = "*.*"]
sb7z sQuelle, sZiel$, zipName, "*.xls"
End Sub
''weitere Infos *************************************************
' a: Add files to archive
' b: Benchmark
' d: Delete files from archive
' e: Extract files from archive (without using directory names)
' l: List contents of archive
' t: Test integrity of archive
' u: Update files to archive
' x: eXtract files with full paths
'
' -ai[r[-|0]]{@listfile|!wildcard}: Include archives
' -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
' -bd: Disable percentage indicator
' -i[r[-|0]]{@listfile|!wildcard}: Include filenames
' -m{Parameters}: set compression Method
' -o{Directory}: set Output directory
' -p{Password}: set Password
' -r[-|0]: Recurse subdirectories
' -scs{UTF-8 | WIN | DOS}: set charset for list files
' -sfx[{name}]: Create SFX archive
' -si[{name}]: read data from stdin
' -slt: show technical information for l (List) command
' -so: write data to stdout
' -ssc[-]: set sensitive case mode
' -ssw: compress shared files
' -t{Type}: Set type of archive
' -v{Size}[b|k|m|g]: Create volumes
' -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
' -w[{path}]: assign Work directory. Empty path means a temporary directory
' -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
' -y: assume Yes on all queries
Gruß Tino