none
How to Zip/Unzip files without using 3rd party component in VBA. RRS feed

  • Question

  • For one of VBA application, We used to zip excel files with password protection through WinZip component. But WinZip tool has been decommissioned due to security reason and replaced by other compression tool.

    So our report generation functionality is not working now as we do not have win zip component in system.

    I have googled and came across some links, but these links do not support password protection features while zip/unzip files.

    https://accessexperts.com/blog/2012/02/06/zipandunzipfrommicrosoftvba/

    http://www.rondebruin.nl/win/s7/win001.htm

    Do we have any generic method to use compression of files with password protection.

    Please anybody suggest me how to use zip/unzip files without using any 3rd party component.

    Thanks & Regards

    Kumar Ravi Shankar

    • Edited by ravibms Monday, November 9, 2015 3:04 PM
    Monday, November 9, 2015 2:09 PM

All replies

  • Try this:

    Unzip

    Zip

    • Proposed as answer by André Santo Monday, November 9, 2015 4:17 PM
    Monday, November 9, 2015 2:56 PM
  • Hi,

    Thanks for your quick reply.

    I went through your suggested link but it does not have any password protection while zip/unzip files.

    These files are very confidential for our client and it is sent through email.

    Please suggest any approach to make zip file as password protected.

    Thanks & Regards

    Kumar Ravi Shankar

    Tuesday, November 10, 2015 12:34 PM
  • Windows XP was the last OS to offer native support for password protected zip files.  Even Win 7 or Win 10 Professional or Ultimate don't offer it.  I don't see any way except a 3rd party tool or writing your own.  Here are a few free libraries that work with .NET and I believe support passwords and self extracting.

    DotNetZip

    SharpZipLib

    Tuesday, November 10, 2015 1:47 PM
  • Hi

    As it looks difficult to compress files with password protected without using 3rd party component.

    so i decided to compress files using SecureZip(pkware) tool.I tried to compress single file into zip file by using command below

    c:\Program Files\PKWARE\PKZIPW>pkzipw -add C:\box\x.zip C:\udba\box\abc.xlsx

    But i am getting error while adding files to archive.

    Error  Message -  "archive being opened but can not be found by secureZip".

    Do we need to pass any additional parameter through command prompt.

    Please suggest me if you have any idea.


    • Edited by ravibms Friday, November 13, 2015 1:26 PM
    Friday, November 13, 2015 1:25 PM
  • I believe the command line program is pkzipc not pkzipw.
    Friday, November 13, 2015 3:59 PM
  • Hi,

    I am planning to go with windows inbuilt compress functionality.

    Unzip

    Zip

    By using that code I am able to Zip all the files available in a folder.
    But it zips all the files inside the containing folder as well as folder itself.
    Lets say we have a default folder named X and containing files are file1,file2. And suppose zip folder is Myzip.zip.
    So after zip I find that Myzip.zip folder contains folder X and inside X we have all the files.

    Our requirement is to zip all the files from containing folder not including folder name.

    Can you suggest any approach to zip files only excluding containing folder.

    Thanks

    Kumar Ravi Shankar

    Wednesday, November 18, 2015 4:48 PM
  • Hi,

    I am planning to go with windows inbuilt compress functionality.

    Unzip

    Zip

    By using that code I am able to Zip all the files available in a folder.
    But it zips all the files inside the containing folder as well as folder itself.
    Lets say we have a default folder named X and containing files are file1,file2. And suppose zip folder is Myzip.zip.
    So after zip I find that Myzip.zip folder contains folder X and inside X we have all the files.

    Our requirement is to zip all the files from containing folder not including folder name.

    Can you suggest any approach to zip files only excluding containing folder.

    Thanks

    Kumar Ravi Shankar

    Thursday, November 19, 2015 6:51 AM