LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Sheet selection on Autoclose

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to AutoClose and Save WANNABE Excel Programming 1 September 23rd 06 12:25 AM
OnTime+TimeValue + Autoclose puba Excel Programming 1 September 7th 06 02:00 PM
Autoclose code from Bob Phillips not working for me Mike K Excel Programming 0 May 9th 06 08:40 PM
Workbook Autoclose ... Srini Excel Discussion (Misc queries) 1 April 24th 05 01:21 PM
Break all links on autoclose killajoules Excel Programming 0 May 10th 04 06:10 AM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"