+ Reply to Thread
Results 1 to 7 of 7

On Error retry SaveAs x times

  1. #1
    Registered User
    Join Date
    11-12-2018
    Location
    Tulsa, OK
    MS-Off Ver
    2016
    Posts
    10

    On Error retry SaveAs x times

    I have a macro that saves a file as a new name after form is filled out. The location that it is saved to is a SharePoint location and the SaveAs sometimes fails due to network connection issues. I would like for the code to wait a couple of seconds and retry the SaveAs step, maybe 5 times before erroring out if it still isn't successful after those 5 tries. I have been trying to test the error loop sections with this code to force it to error, but it seems to only run twice and then throws the 1004 error:

    Please Login or Register  to view this content.
    If this does what I think it should do, it will loop for 10 seconds and then pop-up message box with "did not save". But as I said above it only runs for 4 seconds and then raises the 1004 error box.

    Any help is greatly appreciated.
    Last edited by mrkawht; 04-17-2020 at 02:04 PM.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: On Error retry SaveAs x times

    Possibly with...
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: On Error retry SaveAs x times

    Please use code tags. (forum rule #2)

    I don't think you can do it the way you intended... once inside an error handler (wait), it will not simply "reset". When the code goes to "wait", it is in error handling mode, so your next error doesn't just trigger going back, it actually generates the error. Try this instead:

    Please Login or Register  to view this content.
    Note that the code does not require the ":" in the goto statement, just in the place where you use it as a label.
    Last edited by Arkadi; 04-17-2020 at 01:51 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    11-12-2018
    Location
    Tulsa, OK
    MS-Off Ver
    2016
    Posts
    10

    Re: On Error retry SaveAs x times

    Thanks Arkadi! That is perfect!

    Sorry about the not using code tags. Will do in the future. Don't post very often usually find answers on others posts.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: On Error retry SaveAs x times

    If you could, it would be good if you edit your post to add the tags, it will make it easier to read for others, and like you, they may read this later looking for a similar issue.
    Great that you look for answers/solutions before asking!

    Happy it worked out for you, please remember to mark the thread as solved if you are satisfied. Happy coding!

    p.s. thanks for the rep.

  6. #6
    Registered User
    Join Date
    11-12-2018
    Location
    Tulsa, OK
    MS-Off Ver
    2016
    Posts
    10

    Re: On Error retry SaveAs x times

    Done and done. Thanks again.

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: On Error retry SaveAs x times

    Thanks for that

    And my pleasure!

+ 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] SaveAs, Error.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-07-2017, 09:24 AM
  2. Sumifs - retry
    By Eric Tsang in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-10-2016, 11:52 AM
  3. [SOLVED] .SaveAs error for Word (Error 4198: Command Failed)
    By hoboken in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2015, 06:53 PM
  4. [SOLVED] On error - Retry
    By kenny.fsw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2014, 12:15 PM
  5. [SOLVED] VBA Program works some times and some times gives me a Run-time error '1004'?
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2014, 11:15 PM
  6. [SOLVED] SaveAS Error
    By tigerdel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2012, 09:24 AM
  7. error with saveas....
    By jeramie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2006, 06:45 AM

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