Re: Restricting files to a single computer
- From: Berj <Berj@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Sep 2006 05:56:02 -0700
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
.
- References:
- RE: Restricting files to a single computer
- From: Berj
- Re: Restricting files to a single computer
- From: Bob Phillips
- Re: Restricting files to a single computer
- From: Berj
- Re: Restricting files to a single computer
- From: Bob Phillips
- Re: Restricting files to a single computer
- From: Berj
- Re: Restricting files to a single computer
- From: Bob Phillips
- RE: Restricting files to a single computer
- Prev by Date: RE: Copy latest date from one workbook to another
- Next by Date: Re: Save a copy of particular sheet minus VBA, CommandButton of parent workbook
- Previous by thread: Re: Restricting files to a single computer
- Next by thread: Re: Restricting files to a single computer
- Index(es):
Relevant Pages
|