Help needed with this autosave macro problem

  • Thread starter Thread starter J_J
  • Start date Start date
J

J_J

Hi,

My whole intention is to close the active workbook without beeing prompth by
Windows "do you wanna save the changes....". But unfortunately when I use
the below code I am getting a Compile error with the msgbox
"Procedure declaration does not match description or event procedure having
the same name".
Hope someone can help me to correct this.
 
try

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

Patrick Molloy
Microsoft Excel MVP
 
Ahaa!....
So the trick was to have "cancel as boolean"
Thanks Patrick.
That did it!.
J_J


Patrick Molloy said:
try

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

Patrick Molloy
Microsoft Excel MVP
 
Sometimes, it's better to be lazy.

If you used those dropdowns at the top of the code window in the VBE, then
you'll get the correct name/syntax for those builtin events.

J_J said:
Ahaa!....
So the trick was to have "cancel as boolean"
Thanks Patrick.
That did it!.
J_J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top