Excel file Copy Prevention/Restriction

C

chris100

I have an excel file which i've spent blooming ages working on, and no
that i've come to implement this in our works shop i don't want an
employee copying this file from the computer taking in home, messin
around with it and cracking passwords etc etc...

Solutions to this are few and far between. I tried download.com fo
anything but all i could find was software to prevent unauthorise
copying of .exe files.
Searching the forums here it seems the concensus is that you can'
prevent copying of an excel file, just make it a lot harder.

So, i'd like it if anyone had any ideas to post here so i can make i
as difficult as possible for someone to copy an excel file.

Dave Peterson suggested a macro to check the file path and if it wa
incorrect then fail to proceed etc...

http://www.excelforum.com/showthread.php?t=362625&highlight=copy+prevention+file

I've seen solutions for having a blank page startup unless wit
worksheets very hidden unless a password is entered correctly.

These make it difficult to use an excel file once it has been take
away, but doesn't make it difficult to copy in the first place.

For my own suggestion i'd say have a file that is just once opened
requests a password and then opens the correct file from a hidde
location (i'm sure i've seen this suggested before). This makes it
little harder to copy. But, I'd like to take this one step further.
Is it possible to prevent the search facilty in windows? Because th
problem with the method above is that someone only needs to searc
hidden folders/files to find the file.

I'm all out of suggestions. Anyone else??
 
S

Simon Lloyd

Chris here's a link to where i posed the question
http://www.excelforum.com/showthread.php?t=553507 or you could try
coding in your Auto_open the exact file path i.e if thisworkbook.path
<> "and then put in your filepath to an obscure named folder perhaps"
then KillActive

Try this below, its not fool proof but you can set the file path and if
the workbook is opened not in the specified path it will delete itself!

However, deleting something on another persons computer is classed as
"virus activity" and should not be carried out without you stating your
intentions!

Sub Auto_Open()
If Thisworkbook.Path <> "YOUR PATH HERE" Then
Call KillActive
End If
End Sub

Sub KillActive()
dim sName as String
On Error Resume Next
sName = ThisWorkbook.FullName
Application.DisplayAlerts = False
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill sName
Application.DislayAlerts = True
ThisWorkbook.Close SaveChanges:=False
End Sub
 
J

Jean-Yves

Hello Chris,

Save as PDF ?
as far as security ins concerned, better don't use excel then.

Regards

JY
 
J

Jean-Yves

HI again,
Your suggestion :
For my own suggestion i'd say have a file that is just once opened,
requests a password and then opens the correct file from a hidden
location (i'm sure i've seen this suggested before). This makes it a
Remove the .xls extention from your hidden location or even rename it before
opening it. (just to try confusing people)
Regards
JY
 
C

chris100

Hi guys,

Thanks for the suggestions.
With regards to changing the file extension, i'm not sure how i could
do that and still open the file to run normally. I tried messing
around with saving as different extensions but with no luck.

Mr llyod, i like your method and i'm going to try after i finish this
post. Fortunately the files we use are all in house so we can ignore
the whole virus thing.

Thanks again.
 
C

chris100

Simon,

I tried the "kill" method which i thought was pretty good. I change
the file path as directed but although it killed the file in an
different directory, it also killed it when i tried to open the file i
the correct directory!

I'm no where near an expert at VBA so here is the line of code i use
in case i spazzed somewhere:

If ThisWorkbook.Path <> "C:\Documents an
Settings\Owner\Desktop\TESTDELETE.xls" Then

Opening the file from that location killed it. Please let me kno
where i'm going wrong.

Regards,

Chri
 
S

Simon Lloyd

Chris i read your line and cant imagine that your user name or your area
n the computer is called owner so i assume thats why it deleted the
file, try just dropping the "Owner" portion of your path, but you
should save it in a folder on the desktop because that folder will not
exist on your users desktop!

Just a thought,

Regards,
Simon
 
C

chris100

hi Simon,

Tried what you said but same result. I'll play around with it in the
morning and see if something else works.

regards

chris
 
C

chris100

Just spent a bit of time messing around with this. Really odd. I used
the code below to test and although it ran through to KillActive in a
different directory, it also did the same in the correct directory.

Sub Auto_Open()
If ThisWorkbook.Path <> "C:\Documents and
Settings\OWNER\Desktop\Book2.xls" Then
Call KillActive
End If
End Sub

Sub KillActive()
MsgBox ("heelo")
End Sub

I checked the file path by copying and pasting into Run and it opened
the file fine.

Any ideas, thoughts, suggestions and otherwise help on a postcard
please. :)

Thanks

Chris
 
J

Jean-Yves

Hi Chris,

Change :
If ThisWorkbook.Path <> "C:\Documents and Settings\OWNER\Desktop\Book2.xls"
To
If ThisWorkbook.Path <> "C:\Documents and Settings\OWNER\Desktop"
Regards
JY
 
C

chris100

Thanks Jean-Yves.

I tried what you suggested but still no luck. Could or or anyone else
give this a go to see if it works?

I'm lost!!

Regards,

Chris
 
C

chris100

Having a look around i found this piece of code submitted by Dave
Peterson:

http://www.excelforum.com/showthread.php?t=568158&highlight=check+path+file

option explicit
sub workbook_open()

dim myPath as string
mypath = "c:\book2"

if lcase(me.path) <> lcase(mypath) then
Application.DisplayAlerts=False
me.ChangeFileAccess xlReadOnly
Kill me.FullName
me.Close savechanges:=False
end if

end sub

Working with the above i took the filename back to basics and just kept
it on the C:\ location. It didn't kill the file in the correct location
but nor did it kill in a different location!

What the hell have i done to screw this up?

I'm confused....

P.s obviously be careful using the above code on anything you want to
keep (doh)
 
S

Simon Lloyd

Chris looking at the code it changes the file to read only!, does the
file left on your computer say read only on the top left when you open
it?

Regards,
Simon
 
C

chris100

Hi Simon,

No it doesn't change to read only when opening in the correct or
incorrect location.

Someone hit me with a ficky stick.

Regards,

Chris
 
S

Simon Lloyd

Sorted Chris!, you had the filename in the wrong place and of course i
your using XP, ME, 2000 you have a username which of course was missin
and thats why it would delete anywhere heres the revised code substitut
your own criteria.....P.S i think the folder name is case sensitiv
too!

Regards,
Simon

Option Explicit

Sub Auto_Open()
If ThisWorkbook.Path = "C:\Documents and Settings\Simon\Desktop\Testit
Then
Exit Sub
ElseIf ThisWorkbook.Path <> "C:\Documents an
Settings\Simon\Desktop\Testit" Then
Call KillActive
End If
End Sub

Sub KillActive()
Dim sName As String
On Error Resume Next
sName = ThisWorkbook.FullName
Application.DisplayAlerts = False
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill sName
Application.DislayAlerts = True
ThisWorkbook.Close SaveChanges:=False
End Su
 
C

chris100

Thanks Simon but for some reason it doesn't work. I'm about to kill th
computer instead!

What i'll do is try it out on a different computer if for some reaso
that will make a difference......ummh.

If i haven't thrown the computer out of the window i'll post th
result.

Thanks & Regards,

Chri
 
S

Simon Lloyd

Well Chris it worked fine for me, created a folder called Testit and
saved the workbook in there i then copied the workbook and placed it on
the desktop, when i opened the one on the desktop it got deleted but
when i opened the workbook in the folder Testit it did not get deleted.
I can't understand whats going on with yours?

regards,
Simon
 
C

chris100

Ok Simon, I think i've almmost clocked it.

I was confused thinking that "Testit" in your code was the filename! I
have it now that it works with basic folders e.g c:\Testit\Test2.

I having tested it extensively but i'm pretty sure that was causing the
problem.

Thank you very very very much Simon and others.

You can definately hit me with that Ficky Stick....

Thanks again and regards,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top