PDA

View Full Version : Solved: Savechanges:=False



Philcjr
10-17-2005, 07:07 AM
Need some help here...

I want to close out the activeworkbook (Book2) without saving the file if the user selects "CLOSE"

I have the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.DisplayAlerts = False
ActiveWorkbook.Close Savechanges:=False
Application.DisplayAlerts = True

End Sub


The problem is, if you have a file already open (Book1) and you open the file with the above code (Book2) when you close out "Book2" you can not use any of the commandbars in "Book1" and you have to close out of Excel.

Anyway around this?

Thanks,
Phil

Jacob Hilderbrand
10-17-2005, 09:23 AM
Try this.


Private Sub Workbook_BeforeClose(Cancel As Boolean)

ActiveWorkbook.Saved = True

End Sub

Philcjr
10-17-2005, 09:58 AM
DRJ,
Awesome, that worked!:joy:

Thanks alot,
Phil

Jacob Hilderbrand
10-17-2005, 01:39 PM
You're Welcome :beerchug:

Take Care