ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Marco Run on File Close (https://www.excelbanter.com/excel-programming/312052-marco-run-file-close.html)

Grant

Marco Run on File Close
 
I have a macro that I want to run when/before the file closes.
I tried to call the procedure using the following code, but the procedure
did not run.

Private Sub Workbook_BeforeClose()
Call Clear_Details
End Sub


Any help?

Thanks



Ron de Bruin

Marco Run on File Close
 
Hi Grant

Where have you copy/paste this event ?

It must be in the Thisworkbook module

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Grant" wrote in message ...
I have a macro that I want to run when/before the file closes.
I tried to call the procedure using the following code, but the procedure did not run.

Private Sub Workbook_BeforeClose()
Call Clear_Details
End Sub


Any help?

Thanks





jon

Marco Run on File Close
 
Did you get an error message, or did Clear_Details simply
fail to run?

The location of the code for Clear_Details could cause
this problem. If the code is in a module and the sub is
delcared Private, you won't be able to run it from the
workbook_beforeclose event. Try making it public, or
moving the code to the general declarations section of
the workbook.

-Jon


-----Original Message-----
I have a macro that I want to run when/before the file

closes.
I tried to call the procedure using the following code,

but the procedure
did not run.

Private Sub Workbook_BeforeClose()
Call Clear_Details
End Sub


Any help?

Thanks


.


Grant

Marco Run on File Close
 
That fixed it.

Thanks!



"Ron de Bruin" wrote in message
...
Hi Grant

Where have you copy/paste this event ?

It must be in the Thisworkbook module

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Grant" wrote in message
...
I have a macro that I want to run when/before the file closes.
I tried to call the procedure using the following code, but the procedure
did not run.

Private Sub Workbook_BeforeClose()
Call Clear_Details
End Sub


Any help?

Thanks








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

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