Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide all Sheets in Workbook then Close Workbook
I have a workbook with some sensitive info on certain worksheets. So I
created a BeforeClose_Event that hides all the worksheets when the workbook is closed. I then created a Login UserForm with usernames and passwords so when certain users sign in the code will unhide the worksheets that pretain to that user. The problem is when I click the Red "X" in the top right hand corner it only hides the worksheets and the workbook remains open, why? I want all default features of Excel to remain the same, when the Red X is clicked it gives you the option to save and then the application closes. How do I do that? Private Sub Workbook_BeforeClose(Cancel As Boolean) Windows(ThisWorkbook.Name).Visible = False End Sub Private Sub Workbook_Open() frmLogin.Show End Sub Private Sub cmbLogin_Click() Application.ScreenUpdating = False Select Case cboUserName 'contains all Usernames 'sample of user name code Case "Todd Heller" If tbxPassword = "toddh1" Then With Workbooks(ThisWorkbook.Name) .Unprotect ("AdTech") For wks = 1 To .Sheets.Count .Sheets(wks).Visible = True Next wks .Protect ("AdTech") End With Windows(ThisWorkbook.Name).Visible = True Application.ScreenUpdating = True End Sub Thanks in Advance, Ryan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I hide scroll bars on specific sheets within a workbook | Excel Discussion (Misc queries) | |||
hide non active sheets in workbook | Excel Programming | |||
Hide, not close, one workbook | Excel Programming | |||
How to hide sheets and VBA code in my Excel workbook? | Excel Programming | |||
How to hide sheets and VBA code in my Excel workbook? | Excel Programming |