Thread: Code or Even ?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Code or Even ?

I should have added in hiding the sheets you make them very hidden so if the
workbook is opened with macros disabled the user can't unhide them without
access to your project which you have protected.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
For x = 2 To Worksheets.Count
Sheets(x).Visible = xlVeryHidden
Next
End Sub

Mike

"Mike H" wrote:

Hi,

I doub't there's any foolproff way but you could do this. On closing your
workbook hide all sheets except one with no information in it and have this
in the workbook open event. Substitute xxxx for your computername and note
it's case sensitive.

Private Sub Workbook_Open()
If Environ("Computername") < "xxxxx" Then
ActiveWorkbook.Close savechanges:=False
Else
For Each Worksheet In ThisWorkbook.Worksheets
Worksheet.Visible = True
Next
End If
End Sub

Mike


"Tufail" wrote:

hello all,
is there any code or event that doesn't allow to open my work book in any
other computer ? Yes i am protected my WB with PW.