ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code or Even ? (https://www.excelbanter.com/excel-programming/421658-code-even.html)

Tufail

Code or Even ?
 
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.

Mike H

Code or Even ?
 
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.


Mike H

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.


JLGWhiz

Code or Even ?
 
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"?



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


Mike H

Code or Even ?
 
That's excatly what I meant, thanks for the correction:)

"JLGWhiz" wrote:

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"?



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


Tufail

Code or Even ?
 
thank you so much Mike & JLGWhite........

"Mike H" wrote:

That's excatly what I meant, thanks for the correction:)

"JLGWhiz" wrote:

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"?



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


Mike H

Code or Even ?
 
Glad I could help

"Tufail" wrote:

thank you so much Mike & JLGWhite........

"Mike H" wrote:

That's excatly what I meant, thanks for the correction:)

"JLGWhiz" wrote:

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"?



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



All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com