+ Reply to Thread
Results 1 to 13 of 13

thisworkbook.saved changes inexplicably

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Angry thisworkbook.saved changes inexplicably

    Problem
    I set a conditional break point for every change of the variable thisworkbook.Saved in any routine of any module.
    I set thisworkbook.Saved=true from the immediate window.
    Immediately after, without doing anything else, I press x to close the file
    =>
    the value of the variable becomes false before executing any line of VBA: the trigger takes me to the header of the before_close



    NB if instead of setting the value true to the variable .saved I do a save the problem does not occur: that is, by pressing x the variable .saved remains true

    Any suggestions?

    My program contains tens of thousands of lines of vba and sensitive data so I can't send it, I would like to know if anyone has experienced a similar problem and the relative solution
    alternatively if you can suggest a path to follow to try to understand who / when / how the variable is modified.
    Perhaps there is some other parameter that a real save sets besides the .saved variable that then gets looked at?

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: thisworkbook.saved changes inexplicably

    Mat be other workbook is treated as the one where macros are
    Try in immediate window:
    Please Login or Register  to view this content.
    or make sure workboos with macros is active and use
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    thanks Kaper for the suggestion, unfortunately I tried without getting any changes
    It seems like there are some suspended actions that start when you press "x" (it's the same if I proceed via menu)

    is there any other test to do?

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: thisworkbook.saved changes inexplicably

    Are there volatile functions in the sheets?

    Artik

  5. #5
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,165

    Re: thisworkbook.saved changes inexplicably

    Check in the immediate window whether the state was set.

    e.g.
    ?thisworkbook.Saved
    False
    thisworkbook.Saved=True
    ?thisworkbook.Saved
    True

  6. #6
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    Sorry for the delay in responding I had some small personal problems.
    Yes unfortunately there are volatile functions (including conditional formatting)
    Ok they are volatile but as said after setting the saved status to true I do not perform any action, why do you assume that a recalculation of them starts?
    How can I act?

  7. #7
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    Sorry for the delay in replying, I had some small personal issues.
    Yes, if I print the value of the saved state after setting it, the system correctly returns true

  8. #8
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    @Artik
    Considering my answer, Have you any suggestion?

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: thisworkbook.saved changes inexplicably

    Unfortunately, not having access to the file, I have no way to investigate the cause of this behavior.
    I only suspect that the reason may be conditional formatting. The only thing I can advise is to create a copy of the file, remove all conditional formatting from the workbook. Now investigate if the problem still occurs. If there is no problem, it will indicate that the “culprit” is the conditional formatting (or more precisely, the formulas used in it).

    Artik

  10. #10
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    Thanks Artik,
    I followed your advice but unfortunately even the file without conditional formatting behaves the same way

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,653

    Re: thisworkbook.saved changes inexplicably

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  12. #12
    Registered User
    Join Date
    12-05-2012
    Location
    Rome
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: thisworkbook.saved changes inexplicably

    I managed to narrow down the problem.
    Attached is a very simple file with which to reproduce the bug
    1) open the file
    2) manually change the size of the button by pressing the button with the square (the design mode)
    3) from the immediate window launch
    Please Login or Register  to view this content.
    4) optional, verify that this has had an effect by typing
    Please Login or Register  to view this content.
    it will answer "True"
    5) try to close the sheet
    6) it will ask if we want to save the changes!!!
    7) answer Cancel
    8) type
    Please Login or Register  to view this content.
    again, it will answer "False" !!!

    If instead of the command 3) you do a real save all it will work as expected (i.e. at point 6 the file will close without any questions)

    So what else must be done in VBA to fully simulate the Save command?
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: thisworkbook.saved changes inexplicably

    I confirm that this problem occurs. But, unfortunately, I am not able to understand and explain it.

    Artik

+ 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. Replies: 2
    Last Post: 11-24-2022, 05:49 PM
  2. Date Formats Change inexplicably
    By yankiwibill in forum Excel General
    Replies: 0
    Last Post: 11-26-2014, 09:57 AM
  3. [SOLVED] If then function outputing #NAME error inexplicably
    By yadshpeel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-26-2013, 11:01 AM
  4. ThisWorkbook.Saved at Open()
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2011, 06:44 PM
  5. [SOLVED] Shared Workbook inexplicably grows in size
    By Bob in forum Excel General
    Replies: 0
    Last Post: 08-18-2006, 08:35 AM
  6. Replies: 0
    Last Post: 08-03-2006, 02:50 PM
  7. Problem with ThisWorkBook.Saved
    By PGC in forum Excel General
    Replies: 0
    Last Post: 03-31-2006, 04:10 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