VBA code to check if any changes have occured

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,285
Office Version
  1. 365
Platform
  1. Windows
As part of my current VBA script I give the user the option to save the workbook.

however if the work book as just been opened and no changes have taken place then I don't want to give the user the option.


My idea... If you open a workbook and close it Excel does not prompt you to save, it simply closes. If you make any change you get the do you want to save prompt.

It is possible to identify the variable that controls this and use it for my purpose?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
The following is from VBA help for XL2010 & XL2013. Not sure if it will work on older versions.

The "Saved" property returns True, False or "" ("" = never been saved)

Code:
If Not ActiveWorkbook.Saved Then
 
 MsgBox "This workbook contains unsaved changes."
 
End If
 
Upvote 0

Forum statistics

Threads
1,207,256
Messages
6,077,323
Members
446,278
Latest member
hoangquan2310

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