View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default I am trying to open a ".gz" file with a macro in Excel 2003.

The commandline version exe name is
7z.exe
instead of
7za.exe

On my machine(version 4.65)




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Dave Peterson" wrote in message ...
Without knowing what failed, I'm gonna make a guess that you didn't have the
commandline version of 7z (7za.exe).

You can find it he
http://sourceforge.net/project/downl...ip&use_mirror=

(I haven't used it in a long time, but I believe I went searching for this file
when I needed to do this, too.)

Anyway, this worked for me:

Option Explicit
Sub UnZip_GZFile()
Dim Path7Z As String, FileNameGZ As String
Dim ShellStr As String, FolderName As String

Path7Z = "C:\program files\7-zip\"
'This will check if this is the path where 7za is installed.
If Dir(Path7Z & "7za.exe") = "" Then
MsgBox "Please find your copy of 7za.exe and try again"
Exit Sub
End If

FileNameGZ = "C:\Data\Test.gz"
FolderName = "C:\Data\"

'Unzip the zip file in the folder FolderName
ShellStr = Path7Z & "7za.exe e" _
& " " & Chr(34) & FileNameGZ & Chr(34) _
& " -o" & Chr(34) & FolderName & Chr(34)

ShellAndWait ShellStr, vbHide

MsgBox "Look in " & FolderName & " for extracted files"
End Sub

Remember to include Ron's ShellAndWait code, too.

And after your data is extracted, you can use Dir() to look for what you want
(and open it???).

Joe D wrote:

I have tried modifying Ron's code but unfortunately have not been successful.
I can get it to find the gz files, but not the items inside the files. Any
suggestions would be appreciated.

Thanks
--
Joe D

"Dave Peterson" wrote:

Ron de Bruin has some sample code for zipping files he
http://www.rondebruin.nl/unzip.htm

You can this as the basis for your code--but he does use winzip. You'll have
some minor modifications to do.

Joe D wrote:

I have the 7zip software and can manuially open the files. I am looking for
code to uncompress them with VBA on a windows machine. Any ideas on this??

--
Joe D

"Jacob Skaria" wrote:

.GZ is a gzip compressed file format. (http://www.gzip.org/) You need to
extract the excel file from this.

If this post helps click Yes
---------------
Jacob Skaria


"Joe D" wrote:

Any help would be appreciated.
--
Joe D

--

Dave Peterson


--

Dave Peterson