Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Restrict Use Of Template (Word 2K)

    Users can use all available templates except for one that can be used by 30% of them only. I don't want to put templates in several folders. Is there a way to detect the UserID when a new instance of a template is opened so that a message box can be displayed and, after a while, the new instance is closed without saving? Any help appreciated. Thanks in advance!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Restrict Use Of Template (Word 2K)

    That's going to be tricky. A user could bypass the security by disabling macros, so you'd have to make sure that the document is crippled if macros are disabled. It's much easier to store the template in a folder in which only the appropriate users have permissions.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Restrict Use Of Template (Word 2K)

    If the template is on an NTFS-formatted partition, you can assign user rights to the individual file. This should in theory prevent an unauthorized user from opening the template (or using it to generate a new document), but you have no control over the particular error message that will be displayed.

  4. #4
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restrict Use Of Template (Word 2K)

    I'm looking at a similar problem: I'm being asked to add license management code to my template, and I'm tryinig to figure out all the places I'd have to trap.
    I can trap Document_Open and Document_New, check the license, and then do something nasty like attach to Normal.dot if they're not valid users.

    However, neither of those events gets fired if the user goes to Tools > Templates and Add-Ins and just attaches to the template!
    Voila, toolbars are back, full functionality has woken up!
    I can't create an application events module, because without the _Open or _New events firing, I can't create the object that watches for events.

    Any suggestions?
    I'd hate to have to add license-checking code to each and every macro that would be callable from a toolbar or from Tools > Macros > Macro...

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Restrict Use Of Template (Word 2K)

    How about adding a single bit of license checking code that sets a global variable and then having each and every macro that would be callable check this variable?

    StuartR

  6. #6
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restrict Use Of Template (Word 2K)

    Kind of ugly and expensive on macro storage, but it's what I'm leaning toward.
    The problem is that there's four ways to load a template:
    1) Open a document that's already attached: Document_Open traps that.
    2) Create a new document from the template, or from a document that's attached: Document_New traps that.
    3) Installed as a global template: AutoExec traps that
    4) Attached to an open document with Tools > Templates and Add-Ins. I'm up a creek. Nothing seems to 'happen' when the user does this.

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Restrict Use Of Template (Word 2K)

    You don't need to trap all of these possible events. Just create a single procedure that checks your license and include a call to it at the beginning of each protected procedure. In that licence checking code you could have...
    <code>
    Static blCheckDone as Boolean

    if blCheckDone then exit sub
    <font color=448800>'do your license checks here</font color=448800>
    <font color=448800>'if they fail then output an error message</font color=448800>
    <font color=448800>'and take whatever action you need to, for example</font color=448800> End
    blCheckDone = True
    exit sub
    </code>
    StuartR

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restrict Use Of Template (Word 2K)

    The Document_Open and Document_New events did it for me. Thanks to all!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •