Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Before close and workbook open!

Is this code ok?

Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.ScreenUpdating = False
Worksheets(2).Visible = xlVeryHidden
Worksheets(3).Visible = xlVeryHidden
Worksheets(4).Visible = xlVeryHidden
Worksheets(5).Visible = xlVeryHidden
Application.StatusBar = "Saving..."
ActiveWorkbook.Save
End Sub


Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.StatusBar = "Loading excel file..."
frmSplash.Show

ActiveWorkbook.Worksheets(1).EnableSelection = xlUnlockedCells
Worksheets(1).Activate
ActiveSheet.Range("C4").Select
Worksheets(2).Visible = True
Worksheets(3).Visible = True
Worksheets(4).Visible = True
Worksheets(5).Visible = True
Application.StatusBar = "Ready"
End Sub

Does anyone have some suggestions, and would this work at excel 97?

Thanks in advance?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Before close and workbook open!

Tested in Excel97. Works fine, assuming thast there are at least 5
worksheets and that worksheets(1) is not hidden during the session. Nothing
happens until frmSplash is unloaded, guess that's your intention.

I'd change to this to take care of hidden / added sheets:

Private Sub Workbook_BeforeClose(cancel As Boolean)
Dim L As Long
Application.ScreenUpdating = False
Me.Worksheets(1).Visible = True
For L = 2 To Me.Worksheets.Count
Me.Worksheets(L).Visible = xlVeryHidden
Next
Application.StatusBar = "Saving..."
ActiveWorkbook.Save
End Sub

and a similar method in Open.

HTH. Best wishes Harald



"Marc" skrev i melding
...
Is this code ok?

Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.ScreenUpdating = False
Worksheets(2).Visible = xlVeryHidden
Worksheets(3).Visible = xlVeryHidden
Worksheets(4).Visible = xlVeryHidden
Worksheets(5).Visible = xlVeryHidden
Application.StatusBar = "Saving..."
ActiveWorkbook.Save
End Sub


Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.StatusBar = "Loading excel file..."
frmSplash.Show

ActiveWorkbook.Worksheets(1).EnableSelection = xlUnlockedCells
Worksheets(1).Activate
ActiveSheet.Range("C4").Select
Worksheets(2).Visible = True
Worksheets(3).Visible = True
Worksheets(4).Visible = True
Worksheets(5).Visible = True
Application.StatusBar = "Ready"
End Sub

Does anyone have some suggestions, and would this work at excel 97?

Thanks in advance?




Reply
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 can I close only 1 workbook when I have many open? jpt consulting Excel Discussion (Misc queries) 3 November 30th 04 11:58 PM
Open, print and close workbook despistado[_2_] Excel Programming 2 November 11th 04 04:47 PM
Close Open Workbook David Coleman Excel Programming 1 December 30th 03 05:53 PM
Close Open Workbook Bob Umlas[_3_] Excel Programming 1 December 30th 03 05:50 PM


All times are GMT +1. The time now is 07:38 PM.

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"