+ Reply to Thread
Results 1 to 6 of 6

VBA code to zip file not working

  1. #1
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    VBA code to zip file not working

    Hi,

    So I found a piece of VBA code online which should zip a file.
    This is the code:

    Please Login or Register  to view this content.

    The parameters of the function are set to

    Capture.PNG


    But when I run the code, it is keep looping over this part

    Please Login or Register  to view this content.

    Anyone know why?

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA code to zip file not working

    It could be related to how you're passing the array of files to zip. ParamArray expects multiple values separated with a comma so you need to call it like this:

    Please Login or Register  to view this content.
    Do not try and pass it as an array. If you want to pass an array, change the final parameter in the function:

    Please Login or Register  to view this content.
    Then you can call it like this:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Re: VBA code to zip file not working

    Hi WBD,

    I only have one file to zip, so I am essentially just passing one file to the function.

    I tried what you said in your reply but still no luck

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA code to zip file not working

    Ah. OK. I tried a little test locally on my PC and it worked. I also tried passing a UNC path (as in your example) and that also worked. I'm not sure why it wouldn't work for you.

    WBD

  5. #5
    Forum Contributor
    Join Date
    06-14-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    186

    Re: VBA code to zip file not working

    could it be because the file that I want to zip is saved in a shared network drive that I only have read access to

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA code to zip file not working

    Shouldn't be but you could try zipping up other files or changing the permissions on the file to see if that makes a difference.

    WBD

+ 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. VBA Code with Listbox quit working after file was saved and reopened.
    By nate.oyen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2020, 08:23 AM
  2. [SOLVED] How to use edit (code) if the file is from the list box? i used tag but is not working..
    By Chandria in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2019, 09:38 AM
  3. [SOLVED] Convert some working VBA code to work in VBScript [Test File State]
    By dlow in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-28-2015, 07:52 PM
  4. [SOLVED] Working code to import txt file to sheet.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2014, 04:35 PM
  5. [SOLVED] VBA Find Code not working with XML file like it did in XLS file - Please Help
    By SEOT in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-22-2014, 12:25 PM
  6. Problems working with a shared file contaning VBA Code.-question for the advanced
    By yossiperets in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2013, 04:49 AM
  7. [SOLVED] File Size Code not working
    By briank in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-02-2005, 01:06 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