Consulting

Results 1 to 9 of 9

Thread: Zip a file via VB?

  1. #1
    VBAX Regular
    Joined
    Dec 2011
    Posts
    33
    Location

    Smile Zip a file via VB?

    Is there any way to zip an excel file or any files through VB macro only and without WinZip installed nor any special stand alone zipping tool that can be shelled.

    Thanks...

  2. #2
    Yes you can. I have a class module that does this to Office files to extract its contents and put them back together again. Modify to suit your need:
    http://www.jkp-ads.com/articles/Exce...leFormat02.asp
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location

  4. #4
    Guess where my code came from :-)
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Jan, I am sure that your class is great as is most of your code!

  6. #6
    VBAX Regular
    Joined
    Dec 2011
    Posts
    33
    Location

    Smile

    Thank you for that Jan. I tried fetching the code for zipping the file only but I encountered an error (runtime error 91). Would you please provide just for the zipping files alone as the zipped file is my final touch and no unzipping and zipping 'em back necessary.

    Thanks...

  7. #7
    Rather that updating my code, I'd suggest to use Ron de Bruin's simpler code which only zips:
    http://www.rondebruin.nl/windowsxpzip.htm
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  8. #8
    VBAX Regular
    Joined
    Dec 2011
    Posts
    33
    Location

    Smile

    Thank you again. Sorry but one last request though.

    Rather than browsing the files you want to zip, I would like it to just prompt an input box and I will just paste the path of the files there (e.g. "D:\zipping folder\". The "zipping folder" folder contains the files themselves). Would that be possible? I pray so.

    Thanks so much. You really did help me a lot!

  9. #9
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    First, try Ron's Zip_All_Files_in_Folder_Browse() and post back. The Windows operating system will make a difference.

Posting Permissions

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