AutoOpen not Executing When Document Macros Disabled

A

Art H

If I answer Enable Macros when opening a document containing macros
then both Normal.dot.NewMacros.AutoOpen and then opening document
AttachedTemplate.ThisDocument.Document_Open execute.

If I answer Disable Macros when opening a document containing macros
and VBE is closed Normal.dot.NewMacros.AutoOpen and opening document
AttachedTemplate.ThisDocument.Document_Open do not execute. Other
Normal.dot and AttachedTemplate.macros execute when invoked. Of
course, macros in the opened document do not execute.

If I answer Disable Macros when opening a document containing macros
and VBE is _open_ Normal.dot.NewMacros.AutoOpen executes, but the
opening document AttachedTemplate.ThisDocument.Document_Open does not
execute. Other Normal.dot and AttachedTemplate.macros execute when
invoked. Of course, macros in the opened document do not execute.

In all cases, I start with Word open with no other documents open.

Is this behavior expected? How do I cause
Normal.dot.NewMacros.AutoOpen and opening document
AttachedTemplate.ThisDocument.Document_Open to execute?

Word 2003 SP2, Macros security set to Medium, Windows XP SP 2.
 
J

Jean-Guy Marcil

Art H was telling us:
Art H nous racontait que :
If I answer Enable Macros when opening a document containing macros
then both Normal.dot.NewMacros.AutoOpen and then opening document
AttachedTemplate.ThisDocument.Document_Open execute.

If I answer Disable Macros when opening a document containing macros
and VBE is closed Normal.dot.NewMacros.AutoOpen and opening document
AttachedTemplate.ThisDocument.Document_Open do not execute. Other
Normal.dot and AttachedTemplate.macros execute when invoked. Of
course, macros in the opened document do not execute.

If I answer Disable Macros when opening a document containing macros
and VBE is _open_ Normal.dot.NewMacros.AutoOpen executes, but the
opening document AttachedTemplate.ThisDocument.Document_Open does not
execute. Other Normal.dot and AttachedTemplate.macros execute when
invoked. Of course, macros in the opened document do not execute.

In all cases, I start with Word open with no other documents open.

Is this behavior expected? How do I cause
Normal.dot.NewMacros.AutoOpen and opening document
AttachedTemplate.ThisDocument.Document_Open to execute?

Word 2003 SP2, Macros security set to Medium, Windows XP SP 2.

I am not sure I understand your last question as you have given the answer
in your own first paragraph.

What is it you are trying to do?

Why are you using AutoOpen *and* Document_Open?


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Art H

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











I am not sure I understand your last question as you have given the answer
in your own first paragraph.

What is it you are trying to do?

Why are you using AutoOpen *and* Document_Open?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:http://www.word.mvps.org- Hide quoted text -

- Show quoted text -

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

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

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

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.

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.

Thanks for your time and solutions.

Art
 
J

Jean-Guy Marcil

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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Art H

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



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


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".


See answer to #2.


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
(e-mail address removed)
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
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().

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

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.

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
 
J

Jean-Guy Marcil

Art H was telling us:
Art H nous racontait que :
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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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