Option Explicit
Sub Unzip_Files()
Dim fCounter As Integer
Dim UzipFolderPath As String
Dim oApp As Object
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Add "Zip Files", "*.zip"
.Title = "please select zip files"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "file not selected", vbOKOnly + vbInformation, "Task Cancelled"
Exit Sub
Else
'Extract the files into the newly created folder
Set oApp = CreateObject("Shell.Application")
UzipFolderPath = CurrentProject.Path & "\UnZippedFiles"
MkDir UzipFolderPath
For fCounter = 1 To .SelectedItems.Count
oApp.Namespace(UzipFolderPath & "\").CopyHere oApp.Namespace(.SelectedItems(fCounter)).items
Next
End If
End With
Set oApp = Nothing
End Sub
'************************************************************************
'check this out and let me if it works.
Note: The above code has been written in msaccess
So, if you want to run this in excel. change the above syntax:
* CurrentProject.Path to thisworkbook.path
Sub Unzip_Files()
Dim fCounter As Integer
Dim UzipFolderPath As String
Dim oApp As Object
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Add "Zip Files", "*.zip"
.Title = "please select zip files"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "file not selected", vbOKOnly + vbInformation, "Task Cancelled"
Exit Sub
Else
'Extract the files into the newly created folder
Set oApp = CreateObject("Shell.Application")
UzipFolderPath = CurrentProject.Path & "\UnZippedFiles"
MkDir UzipFolderPath
For fCounter = 1 To .SelectedItems.Count
oApp.Namespace(UzipFolderPath & "\").CopyHere oApp.Namespace(.SelectedItems(fCounter)).items
Next
End If
End With
Set oApp = Nothing
End Sub
'************************************************************************
'check this out and let me if it works.
Note: The above code has been written in msaccess
So, if you want to run this in excel. change the above syntax:
* CurrentProject.Path to thisworkbook.path
No comments:
Post a Comment