+ Reply to Thread
Results 1 to 3 of 3

MS Outlook - Catching overwrite failures (or all errors) when using "SaveAsFile"

  1. #1
    Registered User
    Join Date
    12-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    5

    Question MS Outlook - Catching overwrite failures (or all errors) when using "SaveAsFile"

    Hi,

    I have a simple macro in Outlook (attached to the Quick Access Toolbar) that saves an attachment (one I regularly receive) to a specific location. This works fine and (helpfully) the SaveAsFile method overwrites the file even if it exists.

    But what it does not do is warn if it can't overwrite the file (for example, when it is already open).

    I was wondering how to capture errors (this one and any others in general)?

    Thanks in advance.

    Ryan

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: MS Outlook - Catching overwrite failures (or all errors) when using "SaveAsFile"

    You didn't attach your code for us to check, but I would assume there is an "Application.DisplayAlerts = False" prior to your SaveAs. This causes the app to take the default value, in this case, "Yes", when the overwrite prompt pops up. There is likely also an On Error command that tells the code what to do if an error occurs, and it probably says "On Error Resume Next", which just ignores the error. If that was changed to an On Error Go To directive, you could there check the Err.Number and respond accordingly. Look into the On Error command and the Err object for more info.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Registered User
    Join Date
    12-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    5

    Re: MS Outlook - Catching overwrite failures (or all errors) when using "SaveAsFile"

    Quote Originally Posted by natefarm View Post
    You didn't attach your code for us to check, but I would assume there is an "Application.DisplayAlerts = False" prior to your SaveAs. This causes the app to take the default value, in this case, "Yes", when the overwrite prompt pops up. There is likely also an On Error command that tells the code what to do if an error occurs, and it probably says "On Error Resume Next", which just ignores the error. If that was changed to an On Error Go To directive, you could there check the Err.Number and respond accordingly. Look into the On Error command and the Err object for more info.
    Unfortunately, I couldn't get Application.DisplayAlerts to work with Outlook (I think it might not be available for it?). But On Error worked fine. I had tried that previously, but not sure why it didn't work and I didn't keep a copy of that code to check why. Never mind.

    Thank you!!

+ 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] Overwrite "Allow Access For..." Security Message When Running Code on Outlook
    By XOR LX in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 10-24-2014, 07:07 AM
  2. Replies: 0
    Last Post: 11-20-2012, 10:22 AM
  3. [SOLVED] Macro with "save as" --- Need excel to overwrite a file without a prompt to overwrite
    By tsmith1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 10:54 AM
  4. MSoffice Outlook 2003 message to be saved in C dir with the file name "From" "Sent" "Sub"
    By shailendra0509 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2012, 01:32 AM
  5. Catching "no cells were found"
    By jose luis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2005, 04:05 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