Unzip folder with files to the chosen location

how to unzip subfolders
vba unzip multiple files
vba unzip file with password
visual basic unzip file
access vba unzip file
download and unzip file vba
vba open all files in folder
how to save an access database as a zip file

Team, I am working upon extract the zip file from VBA code but getting error, here is my code:

Sub Un_Zip_File()
Dim flname As String
Call PathCall
flname = Dir(impathn & "Transactions*.zip")
Call PathCall
Call UnZip_File(impathn, flname)
End Sub

Sub UnZip_File(strTargetPath As String, fname As Variant)
Dim oApp As Object, FSOobj As Object
Dim FileNameFolder As Variant

If Right(strTargetPath, 1) <> Application.PathSeparator Then
strTargetPath = strTargetPath & Application.PathSeparator
End If

FileNameFolder = strTargetPath

'destination folder if it does not exist
Set FSOobj = CreateObject("Scripting.FilesystemObject")
If FSOobj.FolderExists(FileNameFolder) = False Then
FSOobj.CreateFolder FileNameFolder
End If

Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(fname).Items

Set oApp = Nothing
Set FSOobj = Nothing
Set FileNameFolder = Nothing

End Sub

When I am running Un_zip_file macro, I am getting error:

Object variables or with block variable not set

after debug moving on

oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(fname).Items

Here is another example how to unzip a file. the macro unzip the zip file in a fixed folder"C:\test\"

Sub Unzip()
    Dim FSO As Object
    Dim oApp As Object
    Dim Fname As Variant
    Dim FileNameFolder As Variant
    Dim DefPath As String

    Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
    If Fname = False Then
        'Do nothing
        'Destination folder
        DefPath = "C:\test\"    ' Change to your path / variable
        If Right(DefPath, 1) <> "\" Then
            DefPath = DefPath & "\"
        End If

        FileNameFolder = DefPath

        '        'Delete all the files in the folder DefPath first if you want
        '        On Error Resume Next
        '        Kill DefPath & "*.*"
        '        On Error GoTo 0

        'Extract the files into the Destination folder
        Set oApp = CreateObject("Shell.Application")
        oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).items

        MsgBox "You find the files here: " & FileNameFolder

        On Error Resume Next
        Set FSO = CreateObject("scripting.filesystemobject")
        FSO.deletefolder Environ("Temp") & "\Temporary Directory*", True
    End If
End Sub

Unzip folder with files to the chosen location, Now create a temporary folder to extract the file: mkdir temp_for_zip_extract . Let's now extract the zip file into that folder: unzip /path/to/file.zip -d  To extract all or individual files from a zipped folder, do the following: Double-click the compressed (zipped) folder. Select the file or files you want to extract. Right-click your selection and click Cut. Navigate to the location you want to unzip the files to. Right-click and select Paste.

Found elsewhere on the web and thought it might help here...

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")
On Error Resume Next
ShellApp.Namespace(unzipToPath).CopyHere ShellApp.Namespace(zippedFileFullName).Items
On Error GoTo 0
End Sub

permissions - How to extract a zip file to a specific folder?, I want all files and subdirectory extracted into /opt directory. How do I extract files in /opt? A. unzip command will list, test, or extract files from a  To unzip the entire folder, right-click to select Extract All, and then follow the instructions. To unzip a single file or folder, double-click the zipped folder to open it. Then, drag or copy the item from the zipped folder to a new location.

I had same error "Object variables or with block variable not set".

Solved it by adding reference to "Microsoft Shell Controls & Automation" - Shell32.dll. Then define & use the Shell object in this order.

Do not skip any of these steps. I have also posted full code in this page.

Dim wShApp As Shell

Set wShApp = CreateObject("Shell.Application")
Set objZipItems = wShApp.Namespace(zipFileName).items  

wShApp.Namespace(unZipFolderName).CopyHere objZipItems

Unzip files in particular directory or folder under Linux or UNIX , unzip <target-zip-file> '<folder-to-extract/*>' -d <destination-path>. works fine on EL 6. On Linux 1. Open Terminal. Click the Terminal app icon, which resembles a black box with a white ">_" on most versions of Linux. 2. Switch to the ZIP folder's directory. Type cd and a space, type the path to the folder in which the ZIP folder is 3. Enter the "unzip" command. Type in unzip

I had exactly the same problem, but in MS Word, trying to extract files from a .zip folder. After a lot of experimentation and testing I discovered that the late-binding objects were not initializing correctly, and when i tested them with the TypeName function were typically "nothing".

I tested my code in both Windows 10 and on an old Windows XP machine, with the same results. All my testing was in Excel 2007 and Excel 2016.

Changing the code from late-binding to early-binding resolved the problem.

Late-binding uses the CreateObject function to initialize the objects in the Shell.Application library. Early-binding requires setting a reference to the "Microsoft Shell Controls and Automation" library in your project.

To set the reference, do this: In the VBA IDE, use the Tools menu to open the References dialog. Scroll through the list of available references until you find the "Microsoft Shell Controls and Automation" entry, and then click the checkbox to select that library, thus: The VBA References dialog, showing the "Microsoft Shell Controls and Automation" library after adding it to your project.

How to extract only a specific folder from a zipped archive to a given , unzip will list, test, or extract files from a ZIP archive, commonly found on The default behavior (with no options) is to extract into the current directory (and option is chosen from DOS's ``Abort, Retry, Fail?'' message, older versions of unzip  How to unzip files with WinZip Launch WinZip from the start menu or Desktop icon. Open the compressed file by navigating to the folder using the WinZip If you only want to unzip some of the files, click on a file in the zip file pane and then check the box to unzip the Click the on the Unzip

unzip -- list, test and extract compressed files in a ZIP archive, Because of this, you'll need to extract the real source files from the you must use to extract the files depends on whether you have chosen to download the CAB, MSI, of the CAB file into a temporary directory where you can work with them. To unzip this file to the current folder, run the following command: unzip sample.zip Unzip several files by listing them all sequentially—e.g., unzip first.zip second.zip third.zip —or by using a wildcard, e.g., unzip *.zip .

Citrix MetaFrame XP: Advanced Technical Design Guide, If you've chosen to save the example Zip file to a location on your computer (​rather Zip files in order to be able to extract (or expand) the contents of the Zip file. go to the TuCows directory of shareware and trialware software programs at  Zip files open the wrong program Some actions can cause the Open With dialog to display when you are working with a Zip file (.zip or .zipx). If this has happened to you, you may have told Windows, by mistake, to use the wrong program to open Zip files.

Cascading Style Sheets (CSS) by Example, Editing the my.ini File To modify the my.ini file, open it with a text tools may extract the archive to a folder within your chosen installation location. Unzip .zip files and unrar .rar files for free online, no installation required! unzip-online.com | Uncompress file This website uses cookies to ensure you get the best experience on our website.

  • Either oApp, oApp.Namespace(FileNameFolder) or oApp.Namespace(fname) may be returning an error. Maybe you should test them before using them?
  • Just going through your code - in the first procedure you use flname = Dir(impathn & "Transactions*.zip") which returns an empty path if the folder doesn't exist, then in your second procedure you assign the path used above to FileNameFolder and then check if it exists - it has to exist otherwise flname will fail.
  • @Dharmendra, you need to add second brackets: oApp.Namespace((FileNameFolder)).CopyHere oApp.Namespace((fname)).Items
  • Welcome to Stack Overflow, please review: stackoverflow.com/help/how-to-answer