gestioperformance
New Member
- Joined
- Mar 29, 2018
- Messages
- 7
Hi everybody,
i'm having issues with the following macro that i want to include in a spreadsheet to prevent the user to give the file to unauthorized third parties. basically, i want to make the file readable only by a specific "computer name".
hereby the macro:
Private Sub Workbook_Open()
Dim cella As Range
Set cella = Sheets(1).Cells(Rows.Count, Columns.Count)
If cella = "" Then
cella = Environ("computername")
ActiveWorkbook.Save
Exit Sub
End If
If cella <> "PC NAME" Then ' username Vale
MsgBox "Unauthorized access", vbCritical, "Access Denied"
ActiveWindow.Close
End If
Set cella = Nothing
End Sub
Thank you in advance for any kind of help.
i'm having issues with the following macro that i want to include in a spreadsheet to prevent the user to give the file to unauthorized third parties. basically, i want to make the file readable only by a specific "computer name".
hereby the macro:
Private Sub Workbook_Open()
Dim cella As Range
Set cella = Sheets(1).Cells(Rows.Count, Columns.Count)
If cella = "" Then
cella = Environ("computername")
ActiveWorkbook.Save
Exit Sub
End If
If cella <> "PC NAME" Then ' username Vale
MsgBox "Unauthorized access", vbCritical, "Access Denied"
ActiveWindow.Close
End If
Set cella = Nothing
End Sub
Thank you in advance for any kind of help.