+ Reply to Thread
Results 1 to 10 of 10

Error Handling - Copy Folder VBA

  1. #1
    Registered User
    Join Date
    09-16-2018
    Location
    Washington State, USA
    MS-Off Ver
    2016
    Posts
    43

    Error Handling - Copy Folder VBA

    I grabbed some VBA online and made a few small edits. The VBA copies a specified folder and allows me to rename and save. Problem is if I click cancel on the dialog box it still saves as a "FALSE". I need it to not overwrite an existing file and also exit the sub if cancel is clicked.

    Sorry, a little new and still learning. Any help would be greatly appreciated!
    Please Login or Register  to view this content.
    Last edited by jsherwood; 09-21-2018 at 02:32 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Error Handling - Copy Folder VBA

    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    09-16-2018
    Location
    Washington State, USA
    MS-Off Ver
    2016
    Posts
    43

    Re: Error Handling - Copy Folder VBA

    Thank you, I updated that.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Error Handling - Copy Folder VBA

    if I click cancel on the dialog box
    which dialogbox ? what is the message with the dialogbox

    It seems thet the dialogbox used are only for display no input

  5. #5
    Registered User
    Join Date
    09-16-2018
    Location
    Washington State, USA
    MS-Off Ver
    2016
    Posts
    43

    Re: Error Handling - Copy Folder VBA

    The save as dialog box. If I click cancel at that point it still copies the folder with the name false.

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Error Handling - Copy Folder VBA

    To avoid misleading can you open the macro and go step by step ( using key F8) and mention when you are asked to save with Cancel option

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Error Handling - Copy Folder VBA

    Got it ... perhaps
    see next code

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-16-2018
    Location
    Washington State, USA
    MS-Off Ver
    2016
    Posts
    43

    Re: Error Handling - Copy Folder VBA

    The save as dialog box opens right after the ToPath = Application.GetSaveAsFilename step. I may have something misplaced here? Fairly new to VBA......appreciate you responding.
    Capture.JPGCapture2.JPG

  9. #9
    Registered User
    Join Date
    09-16-2018
    Location
    Washington State, USA
    MS-Off Ver
    2016
    Posts
    43

    Re: Error Handling - Copy Folder VBA

    Fantastic! Works like a charm! Someday I will be up to this Jedi level.......until then I will be the one asking questions and not responding to them.

    Thank you!

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Error Handling - Copy Folder VBA

    I will be up to this Jedi level
    no, still not at the guru and still learning ...!

+ 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] Copy file from one folder to other - runtime error 53
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2017, 02:49 AM
  2. Error handling inside error handling
    By grantastley in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2015, 03:43 AM
  3. [SOLVED] Error handling when fail to copy file to destination folder
    By mm1234mail in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2014, 04:59 AM
  4. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  5. Error Handling on Copy Sheets
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2011, 01:26 PM
  6. [SOLVED] Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 PM
  7. Error handling with a handling routine
    By ben in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2005, 11:06 AM

Tags for this Thread

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