• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel 2003 Password Protection

pucha

Member
Hello Sir,

Is there any password coding method where an excel file opening in one computer will not open in another unless otherwise a password matching is done.

Actually I had given an excel file to a friend's computer but I don't want that he should open that file in some another computer or pass that file to any of his friend.

Thanks
With Regards
 
The simplest method is to create a small .txt or .ini file. Place that file somewhere inconspicuous on the users computer hard drive. Then when your workbook is opened have it seek that file first. If the file is there, the workbook opens. If it isn't there .....

This small txt file will need to be created only once when your workbook is first opened. So the macro code that performs that action will need to be deleted after the small file is create.
 
pucha
Files can always copy but ...
HardDisk needs more work ...
Code:
Function HdNum() As String
    Dim fsObj As Object
    Dim drv As Object
    Set fsObj = CreateObject("Scripting.FileSystemObject")
    Set drv = fsObj.Drives("C")
    HdNum = Hex(drv.serialnumber)
End Function
 
pucha


Paste the function into a routine module :

Code:
Function HdNum() AsString
   Dim fsObj AsObject
   Dim drv AsObject
   Set fsObj = CreateObject("Scripting.FileSystemObject")
   Set drv = fsObj.Drives("C")
    HdNum = Hex(drv.serialnumber)
EndFunction


This on Sheet 1 , cell A1 , type =HdNum()

Then press ENTER.

In A1 you should see the serial number of your hard drive.
 

Attachments

  • Hard Drive ID.xlsm
    12.9 KB · Views: 5
Is there any other way to protect the excel file.

If you want the Excel workbook to run on only one computer, you'll need to either use the small text file or use the hard drive id #. Either one, the workbook will "read" that information first and compare it to the same information within the workbook. If the two bits of info match, the workbook opens. If they don't match, the workbook closes.

You can password protect the workbook and give the password to the user but that doesn't stop the user from giving away the password along with the workbook also.
 
What i suggest that first run a collector file that will collect info from the each pc then put that serial no in the main file which needs to be protected.

You can't prevent the smart user!!
 
Back
Top