Re: Restricting files to a single computer

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Dear Bob.

It's me again, Berj.
I want to thank you again for the help you gave me.
I include below this note the final code I used. You will see that in it I
have removed the path section, where it checks for the folder.
Now I have another question. I want to ask it to you, since you are the one
who knows about the programming I requested.

As you remember, I requested a code which checks the serial number of a Hard
Disk to open an Excel file. It’s working fine. Now another possible problem
passed my mind:
What if the computer in which the file is, needs to be formatted, or a new
computer is bought and the file has to pass to the new hard disk. Considering
the fact that the file may already contain information which the person does
not want to lose. Of course a backup of the file will be made and then copied
to the new hard disk (with a new serial number!)
Of course it will not open on the new hard disk, since it has a different
serial number than the previous hard disk. So, if it is not opened, I will
not be able to modify the serial number to the new hard disk serial. As a
result, the file will be unusable!
(You see, I work in an area where all my customers can call me, and I am
there personally to solve the problem).

I thought of this for a while, and found a solution in the following way (if
it is possible):
The creation of an external program (EXE extension), which can be copied to
the folder in which the Excel file is. When this external program is
executed, it asks for the Excel filename concerned. It then creates a code in
the Excel file exactly like the one you gave me before (the working version).
This external program also reads the hard disk serial number and fixes it in
the Excel file.
Now, the new code in Excel is executed every time the file is opened,
checking the hard disk serial number.
In this way, even if the original Excel file is copied to a new hard disk,
the Excel file will not open. But if the new external program is executed
there, the code in Excel is renewed (taking in the new hard disk serial
number) and the file now opens.
This external program will be in my possession only, of course.

The same external program can be used maybe (as I think now) for Access,
Word, Excel and PowerPoint files too!

If such a program is possible to make, can you make it and send it to me?
I think this new program may be used by you too…
Below, I include the code which I used in Excel and it worked fine. Use this
one please.

++++++++++++++++++++++++++++++++++++++++++++
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
+++++++++++++++++++++++++++++++++++++++++++++++++

Best regards and thanks in advance,
Berj

.



Relevant Pages

  • RE: Excel file security
    ... Who would you tell that it is the hard disk serial number that they need to ... sheets from your workbook into another workbook that doesn't have your code. ... I have an Excel file which I have prepared to sell to a company. ... asks for a serial number and opens the file without any problems. ...
    (microsoft.public.excel.programming)
  • Excel file security
    ... I have an Excel file which I have prepared to sell to a company. ... The fixed serial number of the hard disk and the ... Function DiskVolumeId(Drive As String) As String ... Private Sub App_WorkbookOpen ...
    (microsoft.public.excel.programming)
  • RE: Distribute calendar.ocx within an excel file ?
    ... "Alan" wrote: ... > excel file, and then check to see if the user has it installed before ... > 2) Check whether the user has it on their hard disk, an if not, ... > 3) Check whether it is registered, and if not, register ...
    (microsoft.public.excel.programming)
  • Re: Opening an Excel File
    ... If your file was copied from the CD onto your hard disk and from there (your ... to the hard drive and unticking the ... >>> drive to a cd before I did a system restore. ... >>> trying to open an Excel file from the cd and I get the following ...
    (microsoft.public.excel.misc)
  • Re: How to start some file as Perl script argument?
    ... You cannot "start" an Excel file because it is not executable. ... then you should have asked how to run an external program. ... outlines the three basic ways of running external commands. ... Fort Worth, Texas ...
    (comp.lang.perl.misc)