Avatar of TimHudspith
TimHudspith
 asked on

How to unzip a gz file with VBA

How can I unzip a compressed file that has the extension '.gz' with VBA?
Microsoft DevelopmentMicrosoft Access

Avatar of undefined
Last Comment
als315

8/22/2022 - Mon
als315

You can install free 7zip archiver (http://www.7-zip.org/) and use shell:
MyFile = "c:\files\test.gz"
Outdir = "c:\out"
Call Shell("c:\Program Files\7-Zip\7z.exe e " & MyFiel & "-o" & Outdir, 1)
Correct path to 7z.exe (you can place it everywhere).
TimHudspith

ASKER
It doesn't work unfortunately. The code executes without error, but the destination directory remains empty.
als315

Try to add quotes before and after path:
MyFile = chr(34) & "c:\files\test.gz" & chr(34)
Outdir = chr(34) & "c:\out" & chr(34)
Cmdstr = "c:\Program Files\7-Zip\7z.exe e " & MyFile & "-o" & Outdir
debug.print CmdStr
Call Shell(Cmdstr,1)
You can test resulting string from command prompt
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
als315

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.