Hey Guys,
I have included the code from This Workbook before save as this error only occurs when I press the save icon up the top left so assuming the problem is here. I have a workbook and a user form where different people can log in. Depending on who logs in dieeretnt sheets are displayed. If you press save the Splash sheet appears down the bottom and if you press save again all other sheets appear If I't not obvious from this code I have a sample wokbook under this thread http://www.excelforum.com/showthread.php?t=1142958. User jake password test1. This is a major problem any help greatly appreciated.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim mySheetVisibilityStructureArray() As mySheetVisibilityStructure
Dim iVisibility As Long
Dim sActiveSheetName As String
Dim cE As clsEvents
Dim csv As clsSheetVis
Dim csL As clsSheetLocked
Set csL = New clsSheetLocked
Set cE = New clsEvents
Set csv = New clsSheetVis
'Initialize the 'Sheet Visibiilty Structure Array'
' ReDim mySheetVisibilityStructureArray(1 To 1)
'Save the 'Active Sheet' Name
sActiveSheetName = ActiveSheet.Name
' 'Verify that the 'Master Sheet' exists
' On Error Resume Next
' iVisibility = Sheets(sSheetNameThatMUST_REMAIN_VISIBLE).Visible
' If Err.Number <> 0 Then
' Err.Clear
' MsgBox "SAVE NOT DONE. Data Integrity Error." & vbCrLf & _
' "In order to save this file Sheet '" & sSheetNameThatMUST_REMAIN_VISIBLE & "' MUST EXIST." & vbCrLf & vbCrLf & _
' "WARNING. If this condition is NOT CORRECTED, Data may be LOST."
' Cancel = True 'Cancel Save
' On Error GoTo 0
' Exit Sub
' End If
' On Error GoTo 0
'// Turn Off All events
cE.AllEvents False
'// Hide all sheets except the one
SheetHide True, sSheetNameThatMUST_REMAIN_VISIBLE
'// On second thoughts (And I'm not rewriting this), any Alerts
'// MUST be displayed
cE.AlertsOn True
'Save this file
ThisWorkbook.Save
'// Restore sheet visibility
csv.Reset
'Resume with the 'Original Active Sheet'
Sheets(sActiveSheetName).Activate
'Cancel Save - to prevent recursion
If bGblDoNotCancelIfCalledFromCloseEvent = True Then
'Do nothing - Prevent Cancel
ElseIf SaveAsUI = True Then
'Do nothing - Prevent Cancel - Allow Save As Dialog Box
Else
Cancel = True
End If
'Reset the Global Called From Save Event Flag
bGblDoNotCancelIfCalledFromCloseEvent = False
Set cE = Nothing
Set csv = Nothing
Set csL = Nothing
End Sub
Bookmarks