Abandoning changes in workbook
On Jul 1, 6:36*pm, Mike H wrote:
Try this
If abcresponse1 = vbNo Then
ThisWorkbook.Saved = True
End If
'do other things
Mike
"Raj" wrote:
Hi,
In the Before close event of the workbook I have the following code:
If ThisWorkbook.Saved = False Then abcresponse1 = MsgBox("Do you want
to Save the file?", vbYesNo)
What should be the code for abcresponse1 = vbNo so that all changes
made to the workbook since it was last saved are abandoned and the
workbook is saved in that state?
The workbook before close event has code further down the line that
has to be processed.
Thanks in advance for the help.
Regards,
Raj- Hide quoted text -
- Show quoted text -
Hi Mike,
Thanks for the response,
When we say vbno = Workbook.saved = True, we are telling Excel not to
prompt with "Do you want so save,etc" later.
My problem is this. The code later in the before close event hides all
the sheets in the workbook. Hence the Workbook.saved become false
again. Now I want the workbook with the hidden sheets saved. When I do
this, the data I do not want to be saved also gets saved.
So, what I am looking for is saving the workbook in the state it was
by abandoning all changes. The data is then in the earlier state. Now
when the worksheets are hidden, the saved workbook has the only the
sheets hidden, but the old unchanged data retained as it is.
So basically I am looking for some code which will save the workbook
without the changes when vbno = Yes rather than changing the state of
the Workbook.saved property, as this will soon get changed to false
again soon as described above.
Thanks, once again.
Regards,
Raj
|