I'm trying to automate unzipping many .gz files on a monthly basis. Previously I used a macro a coworker wrote to do the unzipping using winzip (think he may have used some code snipits from this forum for it - seems like several sites have similar code shown in different postings). But now my office has switched over to pkware's SecureZIP, I can no longer use winzip, and my coworker has moved on. Can I manipulate that old code to work with SecureZIP somehow? I can't seem to find any suggestions on how to do this. Does anyone have any ideas or suggestions on where to start?
VBA Automate Unzip with SecureZip
-
-
Re: VBA Automate Unzip with SecureZip
Hi and welcome to the forum.
I know when I wrote a Winzip routine a while ago it was fairly straight-forward to modify the code for Winrar (see below). What code have you got and what have you tried so far?
Code
Display More'****************************************************************** 'Using WinRar within Excel 'Syntax ' ' RAR <command> [ -<switches> ] <archive> [ <@listfiles...> ] ' [ <files...> ] [ <path_to_extract\> ] '****************************************************************** '************* ' Adding files '************* Sub WinRarIt() Dim WinRarPath As String 'WinRar.exe location Dim RarIt As String 'Command line instruction Dim SourceDir As String 'The source directory Dim SourceFile As String 'The source file Dim Source As String 'The combined Rar from path(s)(FROM) Dim DestDir As String 'The Rarped file directory Dim DestRarName As String 'The Rarped file Dim Dest As String 'The combined Rar to path (TO) '*** Check installation of WinRar *** WinRarPath = "C:\Program Files\WinRar\" If Dir(WinRarPath, vbDirectory) = "" Then MsgBox "WinRar is not installed in the default directory." _ & Chr$(13) & "Archiving of files will not be possible." Exit Sub End If '*** Set the source details *** SourceDir = ThisWorkbook.Path & "\" SourceFile = "This has spaces.xls" Source = SourceDir & "\" & SourceFile 'If source name has one or more spaces surround it with "" If InStr(1, Source, " ", vbTextCompare) <> 0 Then Source = Chr(34) & Source & Chr(34) '*** Set the destination details DestDir = "C:\Rarped Excel Files" 'check that it exists If Dir(DestDir, vbDirectory) = "" Then MkDir DestDir DestRarName = "Test.Rar" Dest = DestDir & "\" & DestRarName If InStr(1, Dest, " ", vbTextCompare) <> 0 Then Dest = Chr(34) & Dest & Chr(34) '*** Do the Rarping *** RarIt = Shell(WinRarPath & "WinRar.exe a " & Dest & " " & Source, vbNormalFocus) End Sub '***************** ' Extracting files '***************** Sub UnWinRarIt() Dim WinRarPath As String 'WinRar.exe location Dim RarIt As String 'Command line instruction Dim SourceDir As String 'The source directory Dim SourceRarFile As String 'The source file Dim Source As String 'The combined Rar from path(s)(FROM) Dim Dest As String 'The combined unRar to path (TO) WinRarPath = "C:\Program Files\WinRar\" If Dir(WinRarPath, vbDirectory) = "" Then MsgBox "WinRar is not installed in the default directory." _ & Chr$(13) & "Archiving of files will not be possible." Exit Sub End If SourceDir = "C:\Rarped Excel Files" SourceRarFile = "Test.Rar" Source = SourceDir & "\" & SourceRarFile If InStr(1, Source, " ", vbTextCompare) <> 0 Then Source = Chr(34) & Source & Chr(34) Dest = "C:\UnRarped Excel Files\" If Dir(Dest, vbDirectory) = "" Then MkDir Dest If InStr(1, Dest, " ", vbTextCompare) <> 0 Then Dest = Chr(34) & Dest & Chr(34) RarIt = Shell _ (WinRarPath & "WinRar.exe e " & Source & " " & Dest, vbNormalFocus) End Sub
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!