View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Kevin Smith[_2_] Kevin Smith[_2_] is offline
external usenet poster
 
Posts: 47
Default Protect Excel Worksheet to be opened on one PC only

You are correct that they can bypass the code but if you password protect the
information then all thay will be able to do is view the data rather than
edit it. on the PC that you specify you will not need to unprotect and
protect the date because that is handled in the code.

it is something that i do with excel and access, i check the ComputerName
and User Name. if it is not me then it protects the data and if it is me then
it allows me full access.
--
Kevin Smith :o)


"Fabian" wrote:

Hi Kevin,

thanks for your answer!

But wouldn't it be possible for the user to not execute macros and to open
the workbook then? OK, it would be protected, but it seems not completely
safe to me.

Fabian

"Kevin Smith" wrote:

Hello,

In the "ThisWorkbook" section in the VBE you can use this code to check the
computer ID and then unprotect the spreadsheet so that it can be edited.

Private Sub Workbook_Open()
If Not Environ("ComputerName") = "YourComputerName" Then
Application.Quit
End If
ActiveSheet.Unprotect Password:="YourPassword"
End Sub

then in the same section use ...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveSheet.Protect Password:="YourPassword", DrawingObjects:=False,
Contents:=True, Scenarios:=True
End Sub

this will password protect your spreadsheet again when you close it.
--
Kevin Smith :o)


"Fabian" wrote:

Hello,

I am looking for a solution to protect an Excel document to be opened on one
computer only. On other computers, the Excel document should show a message
like "This document cannot be opened on this computer" or just fail to open.

The idea is to protect intellectual property in that document (and to
prohibit its usage, so a simple cell protection wouldn't be enough).

Third party solutions would be OK too.

Any answers would be highly appreciated!

Thank you,
Fabian