+ Reply to Thread
Results 1 to 11 of 11

VBA to 7-zip file

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    VBA to 7-zip file

    Hi all

    Does anyone know a code to 7-zip an excel file?

    I am really lost on this one.

    Cheers
    Dan

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA to 7-zip file

    Hi, Dan,

    did you have a look at Zip Activeworkbook, Folder, File or Files with 7-Zip (VBA) and Unzip a zip file with 7-Zip (VBA)?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    Thanks HaHoBe

    I did see this before, but it looks really confusing.
    I was wondering if anyone could direct me to one code to use.

  4. #4
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    Ah, I have it working, however I need this following code to have a password in it, to protect the Zip File

    Any ideas?


    Please Login or Register  to view this content.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA to 7-zip file

    Hi, Dan,

    have a look at -p (set Password) switch and alter the command line code line accordingly.

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    Thanks HaHoBe

    I am still a bit lost as to where I put this line:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA to 7-zip file

    Hi, Dan,

    the code line for compressing in your code is
    Please Login or Register  to view this content.
    You would need to replace that line with
    Please Login or Register  to view this content.
    where secret is the password for the file.

    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    Thanks for your input; however this does not appear to be working.
    It says the file has been zipped, but no zip file is at the location it specifies

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA to 7-zip file

    Hi, Dan,

    as I´m away from my hime PC I can only test the code on Friday evening when I returned. Until then I´d suggest to create a zip archive with the first code supplied and convert that to a password protected archive with the second example.

    I´ll be back his weekend when I have tested what´s wrong with the code supplied.

    Ciao,
    Holger

  10. #10
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    Hi HaHoBe

    Here is a better code, which works but it only zips files individually.
    I would like it to zip all files in the DEST folder

    Your help would be appreciated.

    Cheers Dan


    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: VBA to 7-zip file

    For those interested in 7-zipping a folder: this is what I have used with my code above


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 10-23-2013, 12:54 AM
  2. Save as macro that specifies file type, file location and takes file name from three cells
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-13-2013, 10:09 PM
  3. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  4. [SOLVED] Macro - Master file to import data from another open file with variable file name
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2012, 10:56 PM
  5. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM

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