Self Deleting Macro

L

Luke Moraga

Hi,

I have a document which I am trying to prevent/make it difficult to copy. So
far, I have embedded an AutoOpen macro that detects if the file is not the
original, and if not, tells user that the document is a copy and then closes
the document immediately.

What I would like to do is have the macro also delete the file copy. I can't
figure out how to close the document though, AND continue running macro. Help
please?

Also, any help on how to handle situations where macros are disable would be
appreciated.
 
G

Graham Mayor

There is no way on earth to prevent someone copying a document that you
allow them to see. Certainly a macro solution would take all of five seconds
to circumvent. An auto macro in a document would trigger a security warning
and the user would simply switch off macros.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

Luke Moraga

I understand that. Thankfully, this is more of a precaution to prevent
accidental copying. The people using this document are not very technicallu
adept, and most are trained to just allow macros to run.

Is there no way at all to have a macro delete the file its running from?
 
B

Bear

Luke:

I think the best you could hope for would be to delete the content of the
copy.

If you put your code in an AutoOpen or DocumentOpen subroutine in the
attached macro, you could probably delete the document. But that would depend
on the attached macro being present, which you can't guarantee. Or can you?

Bear
 
K

Karl E. Peterson

Luke Moraga said:
I understand that. Thankfully, this is more of a precaution to prevent
accidental copying. The people using this document are not very technicallu
adept, and most are trained to just allow macros to run.

Is there no way at all to have a macro delete the file its running from?

If you *absolutely* insist <g>, have your macro:

* Create a self-deleting batch file that does the dirty deed
* Set Task Scheduler to run the batch file "a few/ten seconds from now"
* Close the document

For step two, see http://groups.google.com/groups/search?q=task+scheduler+edanmo
 
G

Graham Mayor

I think you are in more danger from the training methods that cause users to
'just allow macros to run'. :( It is only a matter of time before one such
naive user brings in a document from outside the organisation that contains
malicious code.

There is no way you can *guarantee* that users would allow the macros to
run. if you were able to guarantee it then you would be creating a virus
which will lead you into new realms of problems. Macros in distributed
documents are always fraught with problems. Why not supply them with a
template from which they can create the documents without the macros?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

Luke Moraga

Thank you all!

I was able to get copies of the document to delete themselves on opening,
since its being opened in read-only.
 
R

Russ

But it's OK to open the original or a copy in WordPad or some other Word doc
viewer, which doesn't run macros?
 

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