Using some very useful code found on this message board I have set up a user log situated on a hidden sheet. For this to work I need users to enable macros and have used the following to code to attempt to force them to do so:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub
Private sub Workbook_Open()
UnhideSheets
End Sub
Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "Macros Disabled" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub
Private Sub UnHideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub
This works fine except that it unhides the hidden sheet containing the user
log. I need this to remain hidden to give me the ammunition to prove that the file isn't being used.
thanks for looking
Nick
Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub
Private sub Workbook_Open()
UnhideSheets
End Sub
Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "Macros Disabled" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub
Private Sub UnHideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub
This works fine except that it unhides the hidden sheet containing the user
log. I need this to remain hidden to give me the ammunition to prove that the file isn't being used.
thanks for looking
Nick