LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Excel file security

Dear Anyone,

I have an Excel file which I have prepared to sell to a company. But that
company may copy and give it to another company to use. Naturally, I dont
want that to happen. If the second company wants it, they should buy it from
me. Copyrighting is not a solution in my case. I live in a place where I can
reach my customers personally.
As I do not know any programming in Excel, I asked somebody in these forums
on the net to prepare a code in Excel which, before opening the Excel file,
reads the hard disk serial number, compares it to a fixed serial in the code
in order to open the file. The fixed serial number of the hard disk and the
code will be typed by me when the file is first copied to a new hard disk.
From then on, it works fine. But when it is copied to a new hard disk
(someone steals it), it doesnt open because the hard disk serial will be
different of course.
Well, someone answered, and after a few adjustments, the code was made. Good.

This is the code:
========================================
Public WithEvents App As Application
'---------------------------------------------------------------
Function DiskVolumeId(Drive As String) As String
'---------------------------------------------------------------
Dim sTemp As String
Dim iPos As Long
iPos = InStr(1, Drive, ":")
Drive = IIf(iPos 0, Left(Drive, iPos), Drive & ":")
sTemp = Hex(CreateObject("Scripting.FileSystemObject") _
.Drives.Item(CStr(Drive)).SerialNumber)
DiskVolumeId = Left(sTemp, 4) & "-" & Right(sTemp, 4)
End Function

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
If DiskVolumeId("C:") < "E06F-9984" Then
Wb.Close savechanges:=False
End If
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub

Now, as I think of it, another possibility occurred to me. What if the
companys computer was changed, or a problem happened and the hard disk has
to be formatted. In both these cases the hard disk serial number would
change, and the Excel file (even if it was backed up and restored to the new
hard disk) would not be opened. So, the company would lose the information
entered in the Excel file.

Now, I am in need of another addition to the already existing code which
works in the following way:

As the Excel file is opened, it checks and compares hard disk serial with
existing fixed serial in the code. If they match, the file is opened. If not,
instead of closing the file, it asks the question, €śSerial number:€ť. Here the
serial number of the new hard disk has to be entered. (Of course, an operator
would never guess that it is the hard disk serial number). From here on, two
possibilities exist:
a) If the serial number entered is exactly the same as the new hard disk
serial number, the Excel file opens, and the new serial is recorded in the
code such that when the file is opened again on the same hard disk, it never
asks for a serial number and opens the file without any problems.
b) If the serial number entered is not the serial number of the new hard
disk, it answers €śwrong serial number€ť and doesnt open the file without
giving a second chance.

I think maybe this code should work for any Microsoft Office document too.
I hope somebody understood me well and will reply soon.

Regards,
Berj


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File security Excel encryption Trish Smith Excel Discussion (Misc queries) 0 January 18th 09 06:04 PM
Excel 2007 .xlsm file. Macro Security options not available. JP Excel Discussion (Misc queries) 1 July 17th 08 04:04 PM
Security warning when saving downloaded file from Excel codearchitect Excel Discussion (Misc queries) 3 April 5th 07 01:37 AM
Help! Security when using a VBA macro to access an Excel File biker Excel Programming 0 June 16th 06 05:27 AM
Security discussion - how to effectively distribute an Excel file Rémi Excel Programming 4 May 4th 06 05:42 AM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"