Results 1 to 4 of 4

Thread: User Disable Macro

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    1

    Question User Disable Macro

    Hi EveryOne,
    I have a nice problem with Word VBA.
    If the user Disable Macro on document opening, the user
    must NOT see the document. Is there a way to do this ?

    - Thanx a lot

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Re: User Disable Macro

    Originally posted by carltremblay
    Hi EveryOne,
    I have a nice problem with Word VBA.
    If the user Disable Macro on document opening, the user
    must NOT see the document. Is there a way to do this ?

    - Thanx a lot
    Nope. At least not without running code from a source outside the document. If the document macro are disabled, no code would run so Word wouldn't do anything differently than it normally does. If you have a global template loaded, you could use AutoOpen or subclass the application to check document open events and then check to see if the document has macros disabled and if so then close it, but the user would have had to already allowed the global template to open with macros enabled (and not open the document with Shift pressed if you are using AutoOpen). Another option would be to run an executable that constantly checks Word for documents open with disabled macros and closes them.

    A workaround might be to come at it from the other way. Instead of hiding the document if the user disables macros, have the document content hidden in a resource file that is only loaded by a macro. So the document just says "Sorry, you disabled macros. Try again.", but if macros are enabled use an AutoOpen macro to get the contents from the resource document and load them to your document. Then on AutoClose, save the document contents to your resource file and replace the document with the "Sorry, you disabled macros." text.

    The best workaround depends on why you want to hide the document when macros are disabled.

  3. #3
    New Member
    Join Date
    Jun 2005
    Posts
    7

    Re: User Disable Macro

    i had a similar issue in Excel. The way I got around it was to lock everything when you save the file. So if you open the file disabling macros, everything is still locked, if u enable macros, then include some code in ThisDocument
    Private Sub Document_Open()
    End Sub
    to unlock document.
    Also rem to lock document on close

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: User Disable Macro

    you can you sign your macros so the enable macro box won't be shown?
    your signature will have to be added to the trusted signatures in macro security

    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width