ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help needed with this autosave macro problem (https://www.excelbanter.com/excel-programming/322095-help-needed-autosave-macro-problem.html)

J_J

Help needed with this autosave macro problem
 
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.

--------
Private Sub Workbook_BeforeClose()
ActiveWorkbook.Save
End Sub
--------

Regards
J_J




Patrick Molloy[_2_]

Help needed with this autosave macro problem
 
try

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

Patrick Molloy
Microsoft Excel MVP

"J_J" wrote:

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.

--------
Private Sub Workbook_BeforeClose()
ActiveWorkbook.Save
End Sub
--------

Regards
J_J





J_J

Help needed with this autosave macro problem
 
Ahaa!....
So the trick was to have "cancel as boolean"
Thanks Patrick.
That did it!.
J_J


"Patrick Molloy" wrote in message
...
try

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

Patrick Molloy
Microsoft Excel MVP

"J_J" wrote:

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.

--------
Private Sub Workbook_BeforeClose()
ActiveWorkbook.Save
End Sub
--------

Regards
J_J







Dave Peterson[_5_]

Help needed with this autosave macro problem
 
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 wrote:

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

"Patrick Molloy" wrote in message
...
try

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

Patrick Molloy
Microsoft Excel MVP

"J_J" wrote:

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.

--------
Private Sub Workbook_BeforeClose()
ActiveWorkbook.Save
End Sub
--------

Regards
J_J





--

Dave Peterson


All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com