From: JD2 on
Hi Word Gurus,

We are about to roll out Office 2007 across our organisation. One of our
users who is testing the software is running into issues with a special
template that typically runs an autonew macro when it is opened from within
Word. The security in Word is set to disable macros, but when you enable the
content via the option that appears, the autonew macro won't run, so the
initial form doesn't appear.

The template doesn't work properly within Word when we use File, Open
command. However, on testing it myself I noticed it will work OK when run
from Windows Explorer instead (ie. when you tell it to enable the content in
Word 2007 this way, the autorun macro appears).

The autorun macro appears below:

Public Sub MAIN()


ActiveDocument.ShowGrammaticalErrors = True
ActiveDocument.ShowSpellingErrors = True
ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
ActiveWindow.ActivePane.View.ShowAll = False
ActiveWindow.View.ShowFieldCodes = False


Load frmContractInput
frmContractInput.Show

End Sub

Any ideas how we can get it to work from within Word 2007?

Kind regards
JD2

From: Doug Robbins - Word MVP on
The macro you posted is called Main(). If you want a macro to run when a
new document is created from a template by using the File>New menu and then
selecting the template, the macro must be named AutoNew().

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"JD2" <JD2(a)discussions.microsoft.com> wrote in message
news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3(a)microsoft.com...
> Hi Word Gurus,
>
> We are about to roll out Office 2007 across our organisation. One of our
> users who is testing the software is running into issues with a special
> template that typically runs an autonew macro when it is opened from
> within
> Word. The security in Word is set to disable macros, but when you enable
> the
> content via the option that appears, the autonew macro won't run, so the
> initial form doesn't appear.
>
> The template doesn't work properly within Word when we use File, Open
> command. However, on testing it myself I noticed it will work OK when run
> from Windows Explorer instead (ie. when you tell it to enable the content
> in
> Word 2007 this way, the autorun macro appears).
>
> The autorun macro appears below:
>
> Public Sub MAIN()
>
>
> ActiveDocument.ShowGrammaticalErrors = True
> ActiveDocument.ShowSpellingErrors = True
> ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
> ActiveWindow.ActivePane.View.ShowAll = False
> ActiveWindow.View.ShowFieldCodes = False
>
>
> Load frmContractInput
> frmContractInput.Show
>
> End Sub
>
> Any ideas how we can get it to work from within Word 2007?
>
> Kind regards
> JD2
>
From: "Tony Jollans" My forename at my surname dot on
File > Open from within Word, opens the Template; it does not create a new
Document so your AutoNew macro should not run. Double clicking the Template
in Windows (if that is what you are doing), by default, does create a new
Document from the Template and, in those circumstances, your AutoNew macro
should (and does) run.

--
Enjoy,
Tony

www.WordArticles.com

"JD2" <JD2(a)discussions.microsoft.com> wrote in message
news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3(a)microsoft.com...
> Hi Word Gurus,
>
> We are about to roll out Office 2007 across our organisation. One of our
> users who is testing the software is running into issues with a special
> template that typically runs an autonew macro when it is opened from
> within
> Word. The security in Word is set to disable macros, but when you enable
> the
> content via the option that appears, the autonew macro won't run, so the
> initial form doesn't appear.
>
> The template doesn't work properly within Word when we use File, Open
> command. However, on testing it myself I noticed it will work OK when run
> from Windows Explorer instead (ie. when you tell it to enable the content
> in
> Word 2007 this way, the autorun macro appears).
>
> The autorun macro appears below:
>
> Public Sub MAIN()
>
>
> ActiveDocument.ShowGrammaticalErrors = True
> ActiveDocument.ShowSpellingErrors = True
> ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
> ActiveWindow.ActivePane.View.ShowAll = False
> ActiveWindow.View.ShowFieldCodes = False
>
>
> Load frmContractInput
> frmContractInput.Show
>
> End Sub
>
> Any ideas how we can get it to work from within Word 2007?
>
> Kind regards
> JD2
>

From: Navid on
Hi Doug:

According to MS documentation, the sub may be named Main, as long as the
Module is named AutoNew.

However, for many users, myself included, the AutoNew macro does not run
when you open a new document based on a .docm template, while it does so when
creating a new document based on .dot template. Unfortunately, QAT cannot be
customized for specific .dot templates. I have tried all tricks I could
think of, including reducing macro security to a minimum and using properly
imported digital signatures for the macro-containing templates.

Any additional thoughts or ideas would be greatly appreciated.

Best,

Navid

"Doug Robbins - Word MVP" wrote:

> The macro you posted is called Main(). If you want a macro to run when a
> new document is created from a template by using the File>New menu and then
> selecting the template, the macro must be named AutoNew().
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> "JD2" <JD2(a)discussions.microsoft.com> wrote in message
> news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3(a)microsoft.com...

From: Navid on
The solution that worked for my .docm files was the following:

Open the actual template file containing the AutoNew sub.
On the Developer tab click "Document Template" to open the "Templates and
Add-ins" dialog. In the "Templates" tab, click to select the currently open
template's check-box (and it beats me why this has to be selected with this
extra step), click OK then save and close the template.

In my case, the AutNew template now runs when creating new documents based
on the template.

Navid.


"Navid" wrote:

> Hi Doug:
>
> According to MS documentation, the sub may be named Main, as long as the
> Module is named AutoNew.
>
> However, for many users, myself included, the AutoNew macro does not run
> when you open a new document based on a .docm template, while it does so when
> creating a new document based on .dot template. Unfortunately, QAT cannot be
> customized for specific .dot templates. I have tried all tricks I could
> think of, including reducing macro security to a minimum and using properly
> imported digital signatures for the macro-containing templates.
>
> Any additional thoughts or ideas would be greatly appreciated.
>
> Best,
>
> Navid
>