Re: AutoOpen not Executing When Document Macros Disabled

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Art H was telling us:
Art H nous racontait que :

On Mar 8, 6:47 pm, "Jean-Guy Marcil" <DontEvenTry@NoSpam> wrote:
Art H was telling us:
Art H nous racontait que :

Sorry that I was not clear. Here's my questions.

1. Why is macro execution dependent on VBE being open?

Even when no document are opened, the VBE editor considers that
Normal.dot is already opened and accessible, so the macros therein
execute.

2. Why doesn't Normal.dot.NewMacros.AutoOpen always execute
regardless of enabling macros within some document?

On my machine, it always executes, regardless of the Security
settings. I never get a prompt for macros in Normal.dot.
Make sure that under Trusted Publishers ( a tab in the Security
dialog) that you check the "Trust all installed add-in and
templates".

3. Why doesn't AttachedTemplate.ThisDocument.Document_Open always
execute regardless of enabling macros within the document? The
AttachedTemplate is along my template defined path (Workgroup) and
macro security is set to medium.

See answer to #2.

As to your question, Normal.dot.NewMacros.AutoOpen defines
activities that applies to all document (e.g., turn on the review
toolbar) and AttachedTemplate.ThisDocument.Document_Open defines
activites particular to documents based on the AttachedTemplate.

Ah, just got it, you want to make sure that both AutoOpen and
Document_Open execute... If you put your code in the Document_Open
event of Normal.dot, it will not execute when a document based on
another template has code in that template's Document_Open event...

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREM...@xxxxxxxxxxxxxxxxxxxxxxx
Word MVP site:http://www.word.mvps.org

Dear Jean-Guy,

I don't get any prompts regarding macros in Normal.dot either. I also
do not get any prompts in the AttachedTemplate of the document I open.
I selfsigned this template and this template has existed since I was
using Word 2000.

"Trust all installed add-in and templates" has been checked for a long
time. "Trust access to Visual Basic Project is also checked.

I'm confused by the last paragraph as it does not seem to apply to my
situation. I have no code in ThisDocument of Normal.dot. I have code

Sure it does, if your macro in Normal.dot was in the ThisDocument and a
Document_Open type of sub instread of an AutoOpen sub, it would not execute
if you also opened a document whose attached template has a Document_Open
sub. Now, since you have AutoOpen in Normal.dot and Document_Open in the
Attached Template, they both execute.


in a Normal.dot module called NewMacros. In NewMacros, I have three
public routines and two private routines. The first line of these five
routines is as follows:
Sub AutoNew()
Sub AutoOpen()
Sub CreateFooter()
Private Sub ApplyFooterStyletoActiveDocumentFromAttachedTemplate()
Private Sub DefineFooterStyle()

I have another module in Normal.dot named Module1 and Module1 has one
routine named Sub SetUpWord().

In the document that I'm opening I get the prompt whether to enable
macros in that document as I expect. The AttachedTemplate has code in
ThisDocument. In ThisDocument, I have two private routines. The first
line of these routines is as follows:
Private Sub Document_New()
Private Sub Document_Open()
Nowhere in the AttachedTemplate are any modules named AutoNew,
AutoOpen, or AutoExecute. There are no routines called any of these
names either. There is no routine called Main. The AttachedTemplate
does have several other modules and routines. There are no class
modules.

The document that I'm opening has no code in ThisDocument. It has
three public routines in a module called NewMacros. The first line of
these routines is as follows:
Sub DeleteEmptyRowsWithQuery()
Sub DeleteEmptyRowsWithoutQuery()
Sub TrimCellContents()
All of these macros work with Word tables.

When I open the document and select Enable Macros, Normal.dot
AutoOpen() executes followed by AttachedTemplate Document_Open().

Which is normal.

When I open the document and select Disable Macros and VBE is closed,
neither Normal.dot AutoOpen() or AttachedTemplate Document_Open()
execute.

There is something wrong with your setup because the macros in Normal.dot
should execute, even if the security is set to Very High and that you have
checked "Trust all installed add-in and templates" a long time ago as you
stated. (Even when disabling the macros in the attached template, the one in
Normal still execute because they are in a trusted location.)
But, if you place the attached template in the User or Workgroup template
folder, the macros will execute and no prompt will pop up.

It's my understanding that Normal.dot AutoOpen() should execute
regardless of enabling macros contained in some document. Further,
since the AttachedTemplate is signed the Document_Open routine should
also execute regardless of enabling macros contained in the document
that has this template attached to it.

It depends how you signed it and what you did with the certificate...

Please help me understand what's going on or what I need to change so
that the auto macros in Normal.dot and the Document_Open/New macros in
the AttachedTemplate always execute.

Thanks for your assistance and patience.

Art H



--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@xxxxxxxxxxxxxxxxxxxxxxx
Word MVP site: http://www.word.mvps.org


.



Relevant Pages

  • Re: Modules
    ... Could I move the macro in NewMacros in the Duplex ... > template to, say, Module2 and copy it into the My Template so I could keep ... There are many macros in the template and I would like to ... Routines, Declare statements and global variables that are declared using ...
    (microsoft.public.word.vba.beginners)
  • Re: AutoOpen not Executing When Document Macros Disabled
    ... so the macros therein execute. ... particular to documents based on the AttachedTemplate. ... public routines and two private routines. ...
    (microsoft.public.word.vba.general)
  • Re: How to change .attachedtemplate from VBA in Word 2007
    ... while under control of the template which contains the Macro ... does execute this code in Word 2003. ... local copy saved with all the Macros from the Template. ... is never reached) since the .AttachedTemplate is immediate and the ...
    (microsoft.public.word.vba.general)
  • Re: Templates and Macros
    ... including AutoText, AutoCorrect, keyboard assignments, toolbars, macros, ... Here is some general info on moving from Word Perfect to Word: ... As for converting documents from Word Perfect to _use_ in Word... ... this new document as a Word template. ...
    (microsoft.public.word.docmanagement)
  • Re: Understanding Macros
    ... I'm assuming you put the VBA macro code into your forms template. ... Choose an appropriate name for the toolbar ... list, find Macros. ... Okay, I deleted the "Option Explicit" line, ran again. ...
    (microsoft.public.word.docmanagement)