+ Reply to Thread
Results 1 to 7 of 7

Recently amended VBA code causing saving error

  1. #1
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Recently amended VBA code causing saving error

    Hi Guys,

    I have recently added some lines of code onto two sheets. "This workbook" & "Mort Figs". Now when I Close the workbook (x in the top right hand corner of the workbook NOT Excel) it asks me if I want to save. I say yes then it asks me again and again until I say no. There seems to be loop in the programming. If I hit the x in the top right to close excel this does not happen. Any ideas? I have attached a sample
    User Name - Manager
    Password - secret

    Skeleton Tracker.zip
    Last edited by Nitro2481; 01-01-2016 at 07:44 AM. Reason: Forgot to include password

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: Recently amended VBA code causing saving error

    Since you have password protected this workbook, one cannot see all the instances of code and sheets to help you.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Re: Recently amended VBA code causing saving error

    Duhhh

    Sorry. Just noticed that. User - Manager Password - secret

    Sorry

  4. #4
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Re: Recently amended VBA code causing saving error

    These are the two codes I have recently added to.
    "This Workbook"
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Re: Recently amended VBA code causing saving error

    And the other code is

    And "Mort Fig"
    Please Login or Register  to view this content.
    Anyone got any ideas why I'm getting this saving loop when closing the workbook using the x. Does not happen when closing Excel by the x

    Matt

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Recently amended VBA code causing saving error

    Hi Matt,

    Try the following code, with the changes in Red. Unfortunately, if the user presses the 'x' to close the file, and selects 'Cancel', your timer stops.

    The simplest and most reliable way to fix the problem that I know of is to:
    a. Disable the 'x' to close Excel.
    b. Disable the 'x' to close the file.
    c. Disable closing the file from the Excel Menu
    d. Add a CommandButton to Save and Exit.
    e. Add a CommandButton to Exit without Saving.

    Options d. and e. would leave Excel Open if there were other open workbooks.

    ThisWorkbook code module:
    Please Login or Register  to view this content.
    Lewis

  7. #7
    Forum Contributor Nitro2481's Avatar
    Join Date
    09-09-2014
    Location
    Laois, Ireland
    MS-Off Ver
    2013
    Posts
    323

    Re: Recently amended VBA code causing saving error

    Hi Lewis

    that worked perfect. It now allows me close the workbook after saving only once. I notice the timer does stop after pressing cancel, option d & e probably look the best. Is there much in it to do those?
    Matt

+ 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. Subtotal VBA Code Causing Error Stating Excel Not Able To Discern Column Headings
    By Aimee S. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2014, 05:37 PM
  2. [SOLVED] Run time error 1004 - why is the last line of this code causing this?
    By SweetSorcery in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-14-2014, 06:57 AM
  3. [SOLVED] Using Range.clearcontents causing type mismatch error in code
    By Captian LDS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2014, 04:54 PM
  4. Multiple users executing code in .xls file causing error
    By fonzi in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-18-2013, 12:01 PM
  5. Code to find last Column keeps causing an error
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-01-2012, 07:03 PM
  6. Protect/Unprotect code causing out of range error in code
    By Petrolcb41 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2010, 02:34 PM
  7. Saving in the current directory with amended name
    By jram in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2009, 11:00 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