+ Reply to Thread
Results 1 to 13 of 13

Making a Zip Folder

  1. #1
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Making a Zip Folder

    Hi all,

    New to the forum and a beginner at VBA but picking up bits quite well.

    I need to know how to create a new empty Zip folder on my desktop.

    I discovered the MKDir but that just makes a normal folder, I can't add .zip to the path name either.

    I guess because zip is a windows function and not a excel feature I may have difficulty.

    Can anyone help with this? If it helps the zip folder will have a .txt file in

    Thanks in advance

  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,258

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    A Zip folder is a special type of folder because it is actually a file that can contain other files and other zip folders.

    This macro will create a folder named "My Zip Archive" on the Desktop if it does not already exist.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 04-09-2015 at 04:22 PM. Reason: Cleaned up code formatting
    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!)

  3. #3
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Re: Making a Zip Folder

    Thank you for this

    I have tried this and there does not seem to be a folder appear on the desktop or zip folders

    Yet, there is no errors in the scripts

    What am i missing?

    Thanks again

  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,258

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    Copy the code from my last post again. I was having similar trouble but the latest version seems to work fine.

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Making a Zip Folder

    placeholder so I can find this thread later ;-)

  6. #6
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Re: Making a Zip Folder

    Thank you Leith

    This now creates the Dir callled my zip archive but there are no Zip folders present

    The script stops at

    Open DesktopFolder for binary access write as #1

    ??

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

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    Sorry, try this version. I removed the MkDir in the macro. This creates an Empty Zip Folder on the user's Desktop.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Re: Making a Zip Folder

    Amazing!!!

    Thank you Leith. This works.

    If you have time could you show me how to move a .txt file off the desktop into the new zip folder?

    i.e i have a .txt file on the desktop called MyText.txt, how would i get this into the Zip folder. ?

    Thanks once again

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

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    You want to move the file into the folder using VBA, yes?

  10. #10
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Re: Making a Zip Folder

    Yes Leith,

    ideally as an addition to , or separate sub routine move my .txt file off my desktop into the Zip folder

    This is not essential but would be helpful

    Thank You

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

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    Okay, I think we can do that.

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

    Re: Making a Zip Folder

    Hello Urby1Kinobe,

    You will need to change the File path, file name, and filter to what you will be using.

    Please Login or Register  to view this content.
    EDIT: The code has been updated. For some unknown reason, looping through the files using the index number was unreliable. Using For Next works with consistent results.
    Last edited by Leith Ross; 04-09-2015 at 09:02 PM.

  13. #13
    Registered User
    Join Date
    04-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    30

    Re: Making a Zip Folder

    Leith Ross,

    Thank you. This works perfectly

    I appreciate your accurate and timely support

    Thanks again

+ 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. [SOLVED] Code for making new file in same folder as opened file exist.
    By Hydyne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2015, 05:41 AM
  2. Replies: 5
    Last Post: 09-28-2013, 04:32 AM
  3. [SOLVED] Macro for making hyperlinks from auto generated folder dir.
    By lavinius in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-18-2013, 04:01 AM
  4. Making Folder Password Protected using Macro???
    By jesika in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2009, 07:41 AM
  5. Replies: 6
    Last Post: 08-11-2006, 03:41 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