Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default locked VBAProject problems

I was putting finishing touches on my project. Everything was working
fine. Then, I locked the VBAProject. Now I have problems.

The project hides all sheets but one, does a save, then unhides the
sheets. When it unhides it's first sheet, it creates a "sheet tab"
that says Module6 then finishes unhiding sheets. If you open "Module6
tab", excel crashes.

This is spliced together code from the archives. I marked the exact
spot where the "Module6 tab" occurs (----*****).
Any way to fix this? It's excel 97.

Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim fName As Variant
Dim LastSheet As Variant
LastSheet = ActiveSheet.Name
Application.EnableEvents = False
On Error GoTo ErrHandler
Call Workbook_Hide2
Cancel = True
If SaveAsUI Then
fName = Application.GetSaveAsFilename()
If fName = "False" Then
GoTo ErrHandler:
Else
ActiveWorkbook.SaveAs fName
End If
Else
ThisWorkbook.Save
End If
ErrHandler:
Call Workbook_UnHide2
ThisWorkbook.Saved = True
Cancel = True
Application.EnableEvents = True
On Error Resume Next
Worksheets(LastSheet).Select
End Sub

Private Sub Workbook_UnHide2()
Application.EnableEvents = False
Dim s As Integer
' Unhides All Sheets, Hide First Sheet Only
Application.ScreenUpdating = True
For s = 2 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(s).Visible = True
----*****
Next s
ActiveWorkbook.Worksheets(1).Visible = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

Private Sub Workbook_Hide2()
Dim s As Integer
' Hides All Sheets, Unhide First Sheet Only
Application.ScreenUpdating = False
ActiveWorkbook.Worksheets(1).Visible = True
For s = 2 To ActiveWorkbook.Sheets.Count
ActiveWorkbook.Sheets(s).Visible = False
Next s
Application.ScreenUpdating = True
End Sub
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
Programmatically Open Locked VBAProject Michael PE Excel Programming 5 January 3rd 08 05:22 PM
Locked VBAproject due to macro fault???? Simon Lloyd[_573_] Excel Programming 1 October 4th 04 07:22 PM
Locked VBAproject due to macro fault???? Simon Lloyd[_572_] Excel Programming 1 October 4th 04 09:36 AM
Locked VBAproject due to macro fault???? Simon Lloyd[_571_] Excel Programming 1 October 4th 04 09:34 AM
Test for VBAProject Locked from Viewing DennisE Excel Programming 2 January 25th 04 09:02 PM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"