Closing files


Posted by Tim Grollman on October 01, 2001 8:52 AM

How can I close a file in a macro without it bouncing out to ask me if I want to save changes?

Posted by Ian Mac on October 01, 2001 1:24 PM


I'm assuming you want it to save without asking, try:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save = True
End Sub


Any good??

Ian Mac

Posted by Ian Mac on October 01, 2001 1:28 PM

Sorry that's the biggest load of rubbish I've just given you...(NT)


I'm assuming you want it to save without asking, try:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save = True
End Sub


Any good??

Ian Mac

Posted by Ian Mac on October 01, 2001 1:29 PM

Try


I'm assuming you want it to save without asking, try:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub


Any good??

Ian Mac

Posted by Tim on October 02, 2001 4:18 AM


Thanks for responding. In fact I wanted it to close without saving, but I guess changing True into False would fix that, however I'm getting a compile error saying "Expected Function or variable", with the "Save =" highlighted. Do you have any thoughts on that?



Posted by Juan Pablo on October 02, 2001 9:25 AM

Try

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Close SaveChanges:=False
End Sub

Juan Pablo

-------------