I need an AfterSave Event

altiman

New Member
Joined
Feb 24, 2004
Messages
1
Hi,
I want to write a code that let me hide some some sheets before save, then save the workbook and finaly unhide the sheets to continue working with workbook.
Someone
The idea is the workbook always presents the same face (a presentation sheet visible and the others hidden), no matter when or where it was saved.
I have solved this problem in the event of closing the workbook, but i can't figure it out how to make a simple SAVE and continue working.

The BeforeSave event doesn't work because it only saves at the end. So I need a kind of AfterSave event.
Anyone could help?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

NateO

Legend
Joined
Feb 17, 2002
Messages
9,700
Or try the following:

<font face=Courier New><SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> FindWindow <SPAN style="color:darkblue">Lib</SPAN> "user32" Alias "FindWindowA" ( _
    <SPAN style="color:darkblue">ByVal</SPAN> lpClassName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>, _
    <SPAN style="color:darkblue">ByVal</SPAN> lpWindowName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> LockWindowUpdate <SPAN style="color:darkblue">Lib</SPAN> "user32" ( _
    <SPAN style="color:darkblue">ByVal</SPAN> hwndLock <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Workbook_BeforeSave(<SPAN style="color:darkblue">ByVal</SPAN> SaveAsUI <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>, Cancel <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>)
LockWindowUpdate FindWindow("xlMain", vbNullString)
Sheets(1).Visible = <SPAN style="color:darkblue">False</SPAN>
Application.OnTime Now, "ThisWorkbook.Unhde"
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
                
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Unhde()
Sheets(1).Visible = <SPAN style="color:darkblue">True</SPAN>
LockWindowUpdate 0
ThisWorkbook.Saved = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>

Note, it kills your status bar... :whistle:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,101
Messages
5,768,101
Members
425,453
Latest member
bince

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top