View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Autostart macro-protect file

You seem to know how to do it with a macro, but you also know that if macros are
disabled, then this won't work.

Harlan Grove recommended that you add a UDF (user defined function) that is
essentially a do nothing function. But if macros are disabled, then the UDF
will fail.

Then you include this function in very important formulas.

Option Explicit
Function iFunc() As Long
iFunc = 1
End Function


Then in an important/complex formula that returns a number:

=if(...)*someotherformula*ifunc()

If macros are disabled (and depending on the version of excel that the user is
using -- and the user hasn't changed any register settings!), then when the file
is opened with macros disabled, the function will return a #NAME? error.

If you do it in enough spots (and all that other stuff is still true), then you
may stop the user from being able to do anything with your workbook.


Mia wrote:

Hi Dave,

I know that I can´t protect the files totaly.
Anyone as you say that are good i excel can open them,
but I want to protect them from "a normal" user.
I have some wery critical information regarding our
business that I don´t want to be spread outside our firm?

Do you know any way to do this automatic, for
example with a macro? If I can chose I dont
want a password.

--
Best regards
Mia

"Dave Peterson" skrev:

The only effective way to keep people out of your workbook is to not share it
with them.

Anything that depends on a macro means that macros can be disabled--and it's not
too difficult to break into your code and just turn off the things that do the
checking.

You could give the workbook a nice password to open and only share the password
with trusted co-workers, but even those can be broken.

Mia wrote:

Hi,

I have written following code to protect my file from
beeing used from people who shouldent use it. The problem
I have is that you have to activate the macro when you
open the file to get it started, so it don't totaly work.
Do anyone know howe to solv this?

Private Sub Workbook_Open()
If Application.OrganizationName = "Min pc" Then

MsgBox "Hej " & Application.UserName

Else

Application.Quit

End If
End Sub
--

I would be wery grateful for yout help!
Best regards
Mia


--

Dave Peterson


--

Dave Peterson