Open zip file VBA code

superfb

Active Member
Joined
Oct 5, 2011
Messages
251
Office Version
  1. 2007
Platform
  1. Windows
Hi all

I have this code that opens files from the spreadsheet where the user can list the file locations. However i have noticed some of the folders are zip.

VBA Code:
Application.Workbooks.Open strFileName, UpdateLinks:=False, ReadOnly:=True
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
7-zip has a command line you could try
 
Upvote 0
VBA Code:
Option Explicit

Sub UnzipAFile(zippedFileFullName As Variant, unzipToPath As Variant)

Dim ShellApp As Object

'Copy the files & folders from the zip into a folder
    Set ShellApp = CreateObject("Shell.Application")
    ShellApp.Namespace(unzipToPath).CopyHere ShellApp.Namespace(zippedFileFullName).items

End Sub
Sub OpnZip()
    Call UnzipAFile("C:\Users\jimga\Desktop\Newfolder.zip", "C:\Users\jimga\Desktop\New\")
End Sub

VBA code to Zip and Unzip files and folders - Excel Off The Grid
 
Upvote 0
VBA Code:
Option Explicit

Sub UnzipAFile(zippedFileFullName As Variant, unzipToPath As Variant)

Dim ShellApp As Object

'Copy the files & folders from the zip into a folder
    Set ShellApp = CreateObject("Shell.Application")
    ShellApp.Namespace(unzipToPath).CopyHere ShellApp.Namespace(zippedFileFullName).items

End Sub
Sub OpnZip()
    Call UnzipAFile("C:\Users\jimga\Desktop\Newfolder.zip", "C:\Users\jimga\Desktop\New\")
End Sub

VBA code to Zip and Unzip files and folders - Excel Off The Grid
Thank you for this - very much helpful. Although is there a way to not unzip and just open the file to copy data and then close?
 
Upvote 0
is there a way to not unzip and just open the file to copy data and then close?
I am not familiar with code that would do so. I am familiar with WinZip ... it will allow you to temporarily open a zipped file but I am not certain
how you would incorporate WinZip into VBA code.
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,988
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top