Block an excel file

huorsa

Board Regular
Joined
Feb 15, 2002
Messages
101
How can I block an excel file, I mean I just want to be use in certain computers; that if anybody copies the file to another computer it won't work.

Hugo
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Well, one option is to have a list of the computer ID's that you "approve", and in the Workbook_Open() event, read the computer's ID, and If it doesn't find a match in your list, close the file.
 
Upvote 0
Here are a couple of ways to get the names;

Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" _
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

Function GetName() As String
Dim strUserName As String
strUserName = Space(255)
WNetGetUser "", strUserName, 255
GetName = Trim(strUserName)
End Function


Private Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function ComputerName()
Dim strString As String
'Create a buffer 255 should be more then enougth
strString = String(255, Chr$(0))
'Get the computer name
GetComputerName strString, 255
'remove the unnecessary Null characters = chr$(0)'s
strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
'Show the computer name
ComputerName = strString
End Function

HTH


Ivan
 
Upvote 0
The only problem with using a workbook_open event is that the user could turn the application.events off to open the file.

HTH

DRJ
 
Upvote 0
That's not the only concern... security is one tough issue when working with VBA and Excel, and the level you want to take this depends on what you need.

The Workbook_Open is the basic step in security, which could be easily "hacked" by an advanced user.
 
Upvote 0
On 2002-02-18 16:00, DRJ wrote:
The only problem with using a workbook_open event is that the user could turn the application.events off to open the file.

HTH

DRJ

Yes your quite correct....there are other ways to by pass this.....one quick way that comes to mind is to use a small loader file
that opens up this file.....ie. Workbook open protect the MAIN file then have a loader file open this up via code.....

Ivan
 
Upvote 0
A technique that I use is to have a main page and have all the rest hidded and protected. Then have a userform that is called by rightclicking the mouse. This userform allows you to navigate through different pages. If I want to put a time limit for uses of my programs I put it in the workbook_beforerightclick event. That way in order to run the macro it will have to perform the checks that I state. It is not 100% foolproof since excel workbook/worksheet protection is a joke, but it works for me.

HTH

DRJ
 
Upvote 0

Forum statistics

Threads
1,213,483
Messages
6,113,919
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top