< návrat zpět

MS Excel


Téma: rozbalení souboru zipem rss

Zaslal/a 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

Zaslat odpověď >

icon #010615
avatar
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
#010616
avatar
pardon jsem blbej nemyslí mi to. již jsem na to přišel omlouvám se a děkuji za nakopnutícitovat

Uživatelské menu

Nejste přihlášen(a)
avatar\n

Menu

On-line nástroje

Formulář Faktura

Formulář Faktura IV

Oblíbený formulář Faktura byl vylepšen a rozšířen.
Více se dočtete zde.

Aktivní diskuse

Čas od do

lubo • 19.4. 16:30

Makro smyčka

MilanKop • 19.4. 10:46

Makro smyčka

elninoslov • 19.4. 9:02

Čas od do

elninoslov • 19.4. 8:46

Čas od do

jarek1111 • 18.4. 13:46

Čas od do

lubo • 18.4. 11:13

Čas od do

jarek1111 • 18.4. 8:32