thisworkbook.saved changes inexplicably

tomluigi

New Member
Joined
Dec 10, 2018
Messages
9
(Note: I have already posted this question in other groups but have not received any response)

My goal is to close a file without being prompted to save after changing a shape, specifically the size of a button; to this end, after changing the button, I set Thisworkbook.saved to True but if I close the file I am still prompted to save.

NB I don't want to turn off the warnings

NB in the real application, after changing the shape, the user can or cannot change other things before closing, so without this VBA reset I don't know if I have to save or not and I don't want to waste time and annoy the user if it's not the case

To reproduce the problem simply create an empty file, add a ActiveX control button on the sheet, save it and then

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
VBA Code:
ThisWorkbook.Saved = True
4) optional, verify that this has had an effect by typing
VBA Code:
Debug.Print ThisWorkbook.Saved
5) it will answer "True"
6) try to close the sheet
it will ask if we want to save the changes!!!
7) answer Cancel
8) type again
VBA Code:
Debug.Print ThisWorkbook.Saved
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?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Note: I have already posted this question in other groups but have not received any response

Thanks for letting us know, but you need to provide links to those other questions. Thanks

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
You will have to use Application.DisplayAlerts = False in order to not get the pop up. You can use the BeforeClose event to check the value of Workbook.Saved property and show or not show pop up accordingly.
 
Upvote 0
You will have to use Application.DisplayAlerts = False in order to not get the pop up. You can use the BeforeClose event to check the value of Workbook.Saved property and show or not show pop up accordingly.
Thanks for the suggestion but, as written, the problem is precisely in the incorrect value that the workbook.saved property assumes, so I can't use what you indicated.
 
Upvote 0
Okay. Well let me ask this: Would you want the size of the button you changed to be saved when you close?
 
Upvote 0
FYI - The Workbook.Saved property will be set to False if ANYTHING in the Workbook changes. You change a cell value - False. You change the size of a Shape - False. You change the value of a cell to Bold font - False. If you make a change you will be prompted to Save on exit. What exactly are you trying to achieve?
 
Upvote 0
Thanks for letting us know, but you need to provide links to those other questions. Thanks

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Sorry, below the links
stackoverflow
ozgrid
excelforum
 
Upvote 0
FYI - The Workbook.Saved property will be set to False if ANYTHING in the Workbook changes. You change a cell value - False. You change the size of a Shape - False. You change the value of a cell to Bold font - False. If you make a change you will be prompted to Save on exit. What exactly are you trying to achieve?
the real problem is a bit long to explain, here I highlighted the problem:
I make changes that should not be seen as such and therefore after having made them (like shape modification) I reset the value of .saved
I therefore leave the control to the user
=>
- if it does NOTHING the file must close without questions, as hypothesized in the sequence above
- if it makes any changes, such as those indicated by you, is correct asking to save before close
 
Upvote 0
If you're changing the size of the shape programmatically then just enter the Workbook.Save statement after the change is made. And FYI - if you're looking for a real solution to your real problem then you best get to typing. Regardless of explanation length.
 
Upvote 0
If you're changing the size of the shape programmatically then just enter the Workbook.Save statement after the change is made. And FYI - if you're looking for a real solution to your real problem then you best get to typing. Regardless of explanation length.
Exactly what I did! See points 2 and 3 BUT .... I'm here asking for help because it doesn't work, as indicated in point 6
 
Upvote 0

Forum statistics

Threads
1,225,684
Messages
6,186,426
Members
453,354
Latest member
Ubermensch22

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top