Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
i was wondering whether if anyone can help me on this problem. I have this macro that protects the spreadsheet at worksheet and workbook level when i close spreadsheet, however, i discovered a problem when i have mutiple spreadsheets opened together with this particular sheet and exiting excel all together at once. The macro instead of targeting and running the macro for the worksheet it opened with, will just work for top-most opened spreadsheet which i am closing from. I do not want to hardcode the name of the spreadsheet into the macro as this is a generic macros that i use for a lot of my spreadsheets and my spreadsheet will be renamed from time to time. Would really appreciate any help that can be given. Thanks ----------------------------------------------------------------------------------------------- Sub Auto_close() Application.DisplayAlerts = False On Error Resume Next lastSheet = ActiveWorkbook.Sheets.Count For curSheet = 1 To lastSheet Application.Sheets(curSheet).Activate ActiveSheet.Protect ("12345") Next Sheets("Main").Select Range("A1").Select ActiveWorkbook.Protect ("12345") End Sub ---------------------------------------------------------------------------------------------- Rgds Ray |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to AutoClose and Save | Excel Programming | |||
OnTime+TimeValue + Autoclose | Excel Programming | |||
Autoclose code from Bob Phillips not working for me | Excel Programming | |||
Workbook Autoclose ... | Excel Discussion (Misc queries) | |||
Break all links on autoclose | Excel Programming |