PDA

View Full Version : Solved: Disable template???



dchapin
07-07-2008, 05:30 PM
I have created a dot file which is installed into the Word startup directory. I am sending it out to some users as a sort of beta, or demo version. I would like to, based upon a date to stop the template from being usable.

I have added code into the module to do this for some specific forms but would really like to stop someone from using the template at all, after a specific date. The template includes a toolbar and a whole slew of autotext that I would love to be able to stop usage of after the expire date. So am guessing that controlling the use of the entire template would be the only way to go.

I also, as part of this issue have a VERY large and valueable industry specific dictionary that screems to be protected after the expiration date.

Does anyone have any ideas on how any/all of this could be controlled? Any help would be appreciated!!
Dan

Nelviticus
07-08-2008, 03:13 AM
I would recommend not using Word for any kind of security because it can so easily be broken.

Subject to the above caveat you can make your template expire after a certain date with this code:
Public Sub AutoNew()

Const ExpireDate As Date = #6/30/2008#

If DateDiff("d", ExpireDate, Now()) > 0 Then

MsgBox "This template has expired."
ActiveDocument.Close (wdDoNotSaveChanges)

End If

End Sub
Very easy to get around it though.

Regards

fumei
07-08-2008, 10:32 AM
VERY easy to get around.

Sorry, but I have to completely agree with Nelviticus. Forget about any real security regarding Word. It just has not been, is not now, and likely never will be, secure. No Office file is.

Now, there are some sneaky things you could possibly do, but again, there is NOTHING you can do that even a moderately knowledgable person can not hack around.

Here is one sneaky way, but again, it is NOT really secure.

Have two files. The second one is hidden, read-only, password protected.

Use similar code as Nelviticus (although I would use Document_New), but:

1. If the expire date is passed, open the OTHER file in the background.

2. Close the document, just like Nelviticus has.

3. In the code of the OTHER file, have it check the date as well,and then....delete the first file.

You have to do it this way, as you can not have code that deletes the file the code is running from. That is, you can not delete yourself.

Bottom line though is (as someone else phrased): if they can ever see it, it is not, and never can be, secure.

dchapin
07-09-2008, 05:53 AM
Yep, I agree, there are certainly issues with the idea. The dot file will be distributed in a "somewhat" controlled environment, but I wanted to find methods to stop it from being used indeffinately. Thanks for the ideas!

Dan