• 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.

Securing A file

sushilbhansali

New Member
I have a simple Workbook And I am giving it to One Of my friends in a pendrive.
I want a solution that will make that workbook work only when it is in that pendrive.
ie If he tries to copy the workbook into his computer the file wont work or the formulas in the file wont work.
 
Security in Excel is like Swiss cheese, full of holes, your friend can copy and paste anywhere they want.
 
See i dont want to copy protect the file because i also know that preventing copy paste is really difficult.
All i want to do is to make the functionality of the file dependent upon a condition that is fullfilled only when the file is on pendrive.
And then make the condition password protected so that nobody changes it and thus making the file usable only on pendrive.
 
Check this will help..

Code:
Private Sub Workbook_Open()
Dim Drive As Object
With CreateObject("Scripting.FileSystemObject")
    Set Drive = .GetDrive(Left(Application.ThisWorkbook.Path, 2))
        If Drive.DriveType <> 1 Then
            MsgBox "Oops...xl is running outside of defined path.", vbCritical, "Path Error"
            ThisWorkbook.Close False
        End If
End With
End Sub
 
I have a simple Workbook And I am giving it to One Of my friends in a pendrive.
I want a solution that will make that workbook work only when it is in that pendrive.
ie If he tries to copy the workbook into his computer the file wont work or the formulas in the file wont work.
Hi,

Anything you try to do is completely futile. VB solutions only work if the user is kind enough to enable macros. If you allow a user into your file then all control is with that user and not yourself.

Excel protection will deter the honest and provide no protection against anyone with Google and the will to defeat it.
 
Thank You For Your Reply Deepak.

I wanted to know that how does the macro work.
Because if it is dependent upon drive name then if will be hard because the drive name changes when you insert a pendrive when other usb drive is already connected.
 
Thank you for your reply Mike H
But We Can force the users to enable macros.
Hi,

No you can't, Excel security setting cannot be changed by VB code so if a user doesn't enable your macros then that's what happens, they're not enabled. If it was possible then hackers would cause havoc. This question arises time after time and I appreciate that it's important to you but Excel protection cannot provide a robust solution.

There are a couple of workarounds such as this which hides all sheets except for one splash screen so that the workbook is un-usable unless macros are enabled. The problem with this is it can be defeated in minutes and the method of doing it is freely available with a Google search


http://www.vbaexpress.com/kb/getarticle.php?kb_id=379
 
Thank You For Your Reply Deepak.

I wanted to know that how does the macro work.
Because if it is dependent upon drive name then if will be hard because the drive name changes when you insert a pendrive when other usb drive is already connected.

It will encounter on drive type!!!

http://msdn.microsoft.com/en-us/library/office/gg264195(v=office.15).aspx

As said my Mike....
You can make very-hidden all worksheets before workbook_close & enable them with workbook_open as that will force user to enable macro.
 
Back
Top