Autonew macro won't run in Word 2007

  • Follow


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

0
Reply Utf 12/23/2009 4:55:01 AM

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@discussions.microsoft.com> wrote in message 
news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3@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
> 
0
Reply Doug 12/23/2009 5:21:31 AM


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@discussions.microsoft.com> wrote in message 
news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3@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
> 

0
Reply Tony 12/30/2009 6:29:21 PM

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@discussions.microsoft.com> wrote in message 
> news:B94CF4BA-AC08-443E-B78F-D31DFC8596B3@microsoft.com...

0
Reply Utf 1/9/2010 4:56:01 AM

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
> 

0
Reply Utf 1/9/2010 5:17:02 AM

4 Replies
928 Views

(page loaded in 0.11 seconds)


Reply: