Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unpack tar file using VBA

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
A new project I've been assigned to requires me to extract a single file from a tar file and then run some test on the file. I will need to do this same process for about 1000 different tar files. I've already written the macro to handle all the work after the tar file has been unpacked, however I'm not entirely sure how to unpack the tar file using Excel 2003 VBA.

I have tried using the windows default unzip techniques, and as expected it did not work. Does anyone know if the command line winzip can unpack a tar file? Or is there a better method for unpacking a tar file?

Thanks,
BD
 
Try command line
tar -xzf MyFile.tar


[blue]When birds fly in the correct formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness.[/blue]
 
Actually it looks like you have to do that within the tar program, so it probably won't work. The wikipedia article mentions gzip and bzip2; those might be options.

[blue]When birds fly in the correct formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness.[/blue]
 
Correct the command line does not work. Winzip will unpack a tar file just fine. Unpacking it using the GUI is not a problem, however I don't want to do that for 1000 different files. Since I'm just going to unpack to get a single file and then run a macro on the file, I'd like to have the macro also unpack the tar files. This way all I need to do is write the macro and then sit and watch it run. Lazy, but efficient.
 
I found the solution. It was much easier than I expected.

Code:
    Call Shell("C:\Program Files\WinZip\winzip32 -e -o " & "" & _
    "c:\tartest.tar" & " " & "c:\tartest", vbHide)

Hope this helps someone else also.

BD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top