Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
Can you run a macro when you close a workbook or do you have do this through a button? i konw you can run a macro on workbook open but i need it the other way round. if you can't, can you prevent the workbook being closed via the red crox in the corner to force use of the button? thanks in advance, Nigel |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Look in the ThisWorkbook module right window for workbook_close
-- Don Guillett SalesAid Software "Nigel" wrote in message ... Hi, Can you run a macro when you close a workbook or do you have do this through a button? i konw you can run a macro on workbook open but i need it the other way round. if you can't, can you prevent the workbook being closed via the red crox in the corner to force use of the button? thanks in advance, Nigel |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Nigel
In the Thisworkbook Module Private Sub Workbook_BeforeClose(Cancel As Boolean) 'your code here End Sub Gord Dibben Excel MVP On Tue, 29 Nov 2005 08:50:16 -0800, "Nigel" wrote: Hi, Can you run a macro when you close a workbook or do you have do this through a button? i konw you can run a macro on workbook open but i need it the other way round. if you can't, can you prevent the workbook being closed via the red crox in the corner to force use of the button? thanks in advance, Nigel |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() In addition to before close you can use Auto open. for example when I open the file containing the following macro all the sheets are hidden except one that makes the usert select a box that he agrees to the conditions given on the visible page. The accept button runs a macro that unhides the pages. Since this is done automatically at opening it effectively does the same thing as hiding the pages before closing. Sub Auto_open() ' ' Auto_open Macro ' Macro recorded 5/23/2005 by TJLV ' ' ' Sheets("instructions").Select Sheets("opening").Visible = True Sheets("instructions").Visible = False Sheets("reports").Visible = False Sheets("input").Visible = False Sheets("Optimize").Visible = False Sheets("combine").Visible = False Sheets("calc").Visible = False Sheets("split").Visible = False Sheets("Site1").Visible = False Sheets("Site2").Visible = False Sheets("Siteagg").Visible = False Sheets("rates").Visible = False End Sub -- TJLV "Nigel" wrote: Hi, Can you run a macro when you close a workbook or do you have do this through a button? i konw you can run a macro on workbook open but i need it the other way round. if you can't, can you prevent the workbook being closed via the red crox in the corner to force use of the button? thanks in advance, Nigel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect Workbook vs Worksheet?? | Excel Worksheet Functions | |||
Macro Help In Excel | Excel Discussion (Misc queries) | |||
Applying same macro to all worksheets in workbook | Excel Discussion (Misc queries) | |||
close only one workbook | New Users to Excel | |||
Copying a workbook with custom toolbar assigned to a macro | Excel Discussion (Misc queries) |