Re: Allow Use Of Workbook On Specific Computers Only
Quote from Simon Lloyd;441226
You would do something like:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Sht As Worksheet
Sheets("Welcome").Visible = True
For Each Sht In Sheets
If Sht.Name = "Welcome" Then
Else
Sht.Visible = xlVeryHidden
End If
End Sub
Private Sub Workbook_Open()
Dim Sht As Worksheet
If Environ("computername") <> "MACHINE NAME" Then Exit Sub
For Each Sht In Sheets
Sht.Visible = True
End If
Sheets("Welcome").Visible = False
End Sub
Display More
where "MACHINE NAME" would be the actual name of your computer i.e "Warriors PC"
I tried your example, but had problems with it's execution. I made modifications and added a security bypass password. Your example was great at getting me to understand how this works. It just needed some tweaks. My (and your) code is below. Thanks for the help!!!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Sht As Worksheet
Sheets("ENTER").Visible = True 'ENTER is the name of the sheet I want visible when opening Excel workbook
Sheets("ENTER").Select
For Each Sht In Sheets
If Sht.Name = "ENTER" Then
Else
Sht.Visible = xlVeryHidden 'Hide each sheet that is not named ENTER
End If
Next Sht
End Sub
Private Sub Workbook_Open()
Dim Sht As Worksheet
Dim Pass
If Environ("computername") <> "GOOBERS-PC" Then 'EXAMPLE...GOOBERS-PC is the name of the computer in windows...
' ...to find computer name, right click on Computer icon and look for "Computer name:", or...
' ...Control Panel, then System and look for "Computer name:"
For Each Sht In Sheets
If Sht.Name <> "ENTER" Then
Sht.Visible = xlVeryHidden
End If
Next Sht
MsgBox "Incorrect Machine Config...Email &amp;quot;[email protected]&amp;quot;[/email]" ' OPTIONAL PASSWORD TO BYPASS SECURITY-START HERE v
Pass = InputBox("Who Are You?", "Who Box")
If Pass = "obamaSUX" Then 'obamaSUX is the password to jup security
For Each Sht In Sheets
Sht.Visible = True
Next Sht
Sheets("MAIN").Select ' MAIN is the name of the sheet I want to jump to after entering password
Range("A1:N1").Select
Else: Exit Sub
End If ' - END HERE ^
Else
For Each Sht In Sheets
Sht.Visible = True
Next Sht
End If
End Sub
Sub ENTER1()
' Form control button on sheet named ENTER to jump to sheet named MAIN ...
'...when entering workbook
' ENTER1 Macro
'
'
If Environ("computername") <> "GOOBERS-PC" Then
MsgBox "Incorrect Machine Config...Email &amp;quot;[email protected]&amp;quot;[/email]"
Else
Sheets("MAIN").Select
Range("A1:N1").Select
End If
End Sub