< návrat zpět
MS Excel
Téma: rozbalení souboru zipem
Zaslal/a dream2003 11.12.2012 13:58
dobrý den, potřeboval bych radu nebo jestli by šlo upravit kod pro rozbalení soubru 7.zip přičemž jméno souboru se stále mění to je zbobrazeno v excelu pokud by se neměnilo nebyl by to problém našel jsem tenhle kod
Sub B_UnZip_Zip_File_Fixed()
Dim PathZipProgram As String, NameUnZipFolder As String
Dim FileNameZip As Variant, ShellStr As String
'Path of the Zip program
PathZipProgram = "C:\program files\7-Zip\"
If Right(PathZipProgram, 1) <> "\" Then
PathZipProgram = PathZipProgram & "\"
End If
'Check if this is the path where 7z is installed.
If Dir(PathZipProgram & "7z.exe") = "" Then
MsgBox "Please find your copy of 7z.exe and try again"
Exit Sub
End If
'Create path and name of the normal folder to unzip the files in
'In this example we use: Application.DefaultFilePath
'Normal if you have not change it this will be your Documents folder
'The name of the folder that the code create in this folder is the Date/Time
'NameUnZipFolder = Application.DefaultFilePath & "\" & Format(Now, "yyyy-mm-dd h-mm-ss")
'You can also use a fixed path like
NameUnZipFolder = "I:\práce\VBA\"
'Name of the zip file that you want to unzip (.zip or .7z files)
FileNameZip = "I:\práce\VBA\SC_WH_supp_dep_p_02-dec-12_02-dec-12.zrp.Z"
'There are a few commands/Switches that you can change in the ShellStr
'We use x command now to keep the folder stucture, replace it with e if you want only the files
'-aoa Overwrite All existing files without prompt.
'-aos Skip extracting of existing files.
'-aou aUto rename extracting file (for example, name.txt will be renamed to name_1.txt).
'-aot auto rename existing file (for example, name.txt will be renamed to name_1.txt).
'Use -r if you also want to unzip the subfolders from the zip file
'You can add -ppassword if you want to unzip a zip file with password (only .7z files)
'Change "*.*" to for example "*.txt" if you only want to unzip the txt files
'Use "*.xl*" for all Excel files: xls, xlsx, xlsm, xlsb
ShellStr = PathZipProgram & "7z.exe x -aoa -r" _
& " " & Chr(34) & FileNameZip & Chr(34) _
& " -o" & Chr(34) & NameUnZipFolder & Chr(34) & " " & "*.*"
ShellAndWait ShellStr, vbHide
MsgBox "Look in " & NameUnZipFolder & " for extracted files"
End Sub
děkuji za návrhy
AL(11.12.2012 14:41)#010615 Však to tam máš napísané:
'Name of the zip file that you want to unzip (.zip or .7z files)
FileNameZip = "I:\práce\VBA\SC_WH_supp_dep_p_02-dec-12_02-dec-12.zrp.Z"
Čiže, pokiaľ chceš názov súboru meniť, tak do premennej FileNameZip nebudeš ukladať reťazec "I:\práce\VBA\SC_WH_supp_dep_p_02-dec-12_02-dec-12.zrp.Z", ale budeš do nej načítať názov súboru vrátane fullpath, ktorý máš, ako hovoríš, uložený v nejakom excelovskom súbore...
citovat
dream2003(11.12.2012 14:51)#010616 pardon jsem blbej nemyslí mi to. již jsem na to přišel omlouvám se a děkuji za nakopnutí
citovat