+ Reply to Thread
Results 1 to 14 of 14

Zipping file from excel

  1. #1
    Registered User
    Join Date
    05-31-2007
    Posts
    10

    Zipping file from excel

    hi,

    I have a task of zipping many files and the path of these files are specified in a excel file too. Is there any way of creating a macro in excel to zip the files specified in the path with a name specified in the excel and encrypt if possible.

    Tks
    MS

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mohanss82,

    Here is a macro to Zip a file using VBA. This includes error handling.
    Please Login or Register  to view this content.
    Example of using the macro
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-31-2007
    Posts
    10
    Hi Leith Ross,

    Thanks for the prompt response.

    below is the format I use, tell me where the macro needs to edited to suit my below format.

    Sl.No Name Path Zip Name Password
    1 Mohan C:\Temp Test 123

    Tks
    MS

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mohanss82,

    I don't follow your method for creating the path for the file to be zipped. Will you be reading file names from a worksheet? What else is being added to the file name? Do you want to password protect the Zip file?

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    05-31-2007
    Posts
    10
    Yes sir..

    I want the files to be ziped using the names in excel and encrypt with the passwod given in the same excel.

    Is this possible

    Tks
    MS

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mohanss82,

    Yes. I will need to see your worksheet. Please post the your workbook for review.

    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    05-31-2007
    Posts
    10
    thanks leith,

    see the attached template.

    We create the folders for each person on the basis of emp id as per Column B so path will unique and also the file name used for zip will be unique.

    tks
    MS
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mohanss82,

    The delay was unavoidable. Whenever we get rain where I live, there seems to be no end to connection problems or power problems. I have added the 2 macros shown below to the attached workbook. There is button on the worksheet to run the macro.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-31-2007
    Posts
    10
    Hi leith,

    thanks for ur time.

    I tried running the macro, and got a messg, "File not Found".

    Required some more of ur time

    Tks
    MS

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello mohanss82,

    "File not found" can be caused by several things. The file path or file name may be mistyped, or the file folder doesn't exist or the file doesn't exist.

    Sincerely,
    Leith Ross

  11. #11
    Registered User
    Join Date
    03-12-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    3

    Re: Zipping file from excel

    Hi Leith,

    Thank you so much, I have been looking for this past one month and finally I am find it.

    need a help here
    I want the password to be combination of two columns and destination folder for the zipped files to a different one than in the path.

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Zipping file from excel

    Hello Mr. Leith
    It seems to me that the attachment in Post #8 doesn't work properly
    I have the path and file name and got the same error "File Not Found"
    how to make it work?
    Thanks advanced for help
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Zipping file from excel

    Hello YasserKhalil,

    The method for zipping files has changed since this post was first written. The code here will only work with Office XP and earlier.

    In 2007 Microsoft changed how Windows zipped files. Do you want to add a file to a zip folder (archive), zip a file, or zip a folder?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Zipping file from excel

    Thanks a lot Mr. Leith for reply
    I need to zip a file with password by code
    Thanks advanced for help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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