Code or Even ?

T

Tufail

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.
 
M

Mike H

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
 
M

Mike H

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
 
J

JLGWhiz

Hi Mike, You wrote "Substitute xxxx for your computername and note
it's case sensitive."

Did you mean "Substitute your computername for "xxxx" and note
it's case sensitive"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top