+ Reply to Thread
Results 1 to 8 of 8

Unzip file through VBA

  1. #1
    Registered User
    Join Date
    08-14-2012
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    35

    Unzip file through VBA

    Hi, I am trying to unzip all .zip files which are in a folder. The files will be unzipped to the same folder and the .zip file should be deleted after unzipping. Below is my code. When I try to run, I get an error "Run time error '91': Object variable or With block variable not set" at the red line below.

    I googled a lot to resolve this but in vain. I am running Excel 2010 32 bit on Windows 7 64 bit. I think this has got to do with setting Tools -> References but I dont know which one it is. Your help is much appreciated.


    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 11-12-2012 at 12:55 AM. Reason: Added code tags, as per forum rules. Don't forget!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Unzip file through VBA

    Is this any better?
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Unzip file through VBA

    What is "Fname" in this line? I would say that is where your problem is for this error. I have not cheacked the rest of the code though to see if this will work.
    Edit : never mind
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Unzip file through VBA

    try giving it a zip extention to return files for.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    08-14-2012
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Unzip file through VBA

    Thanks for the suggestion but these didnt work.

    @JBeaucaire: I used CVar but in vain
    @Japan: It is the filename
    @Andy: The loop is correctly picking up my zip file when I debug, so that is not a problem

    Anyone have any suggestions or faced similar problem before. Anyone know the Tools->Reference setting for working with zip files.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Unzip file through VBA

    you need to fully qualify, including the folder location, the items to be qualified

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-14-2012
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Unzip file through VBA

    Thanks Andy. This one worked.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Unzip file through VBA

    If that takes care of your original query, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1