Results 1 to 5 of 5

Thread: Stop the "Do you want to save changes" prompt

  1. #1
    VBAX Regular
    Joined
    Aug 2010
    Posts
    10
    Location

    Question Stop the "Do you want to save changes" prompt

    I wrote a macro and this macro creates a new WorkBook. The last few lines in the macro are Erase lines and just before those lines, I have
    MyNewWorkbook.Saved = True
    However, when I click the x button in the workbook (top right corner), I get the "Do you want to save changes" prompt. Did I miss something?

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    452
    Location
    Try just:

    MyNewWorkbook.Save

    But if this is a new workbook, probably need SaveAs to designate destination.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VBAX Regular
    Joined
    Aug 2010
    Posts
    10
    Location
    The line of code I showed is the line after the MyNewWorkbook.Save line. It was a failed attempt at addressing the issue.

  4. #4
    Make sure the MyNewWorkbook.Saved = True is the last line of the routine. But, if your file contains any volatile functions like TODAY, NOW or INDIRECT, there is nothing you can do to prevent this message.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  5. #5
    VBAX Regular
    Joined
    Aug 2010
    Posts
    10
    Location
    Gotcha. Currently, there are some erase lines after that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •