AutoOpen not running

T

TedMi

I need to open a doc from an Access form. Works fine, except the doc's
AutoOpen does not run. Here's the code:

Dim oWord as Object
Set oWord = GetObject("C:\Data\Merge1.doc")
oWord.Application.Visible = True

This creates a minimized instance of Word with the named doc open. The
prompt to enable/disable macros does appear, but the AutoOpen does not run.
It runs fine when opened from Word File Open or by double clicking its name.
The AutoOpen is in the doc, not normal.dot.

What the Auto does is reset merge data source to an Access file in the local
directory. Any suggestions?
 
T

Tony Jollans

Auto macros do not run when starting Word using Automation. You must
explicitly run them ..

[Document_Ref].RunAutoMacro wdAutoOpen
 
T

TedMi

Thanks for the answer. Auto macros run SOMETIMES under Automation. I changed
my code to this, and AutoOpen runs!

Dim oWord as Object
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open FileName:="C:\..."
--
Ted


Tony Jollans said:
Auto macros do not run when starting Word using Automation. You must
explicitly run them ..

[Document_Ref].RunAutoMacro wdAutoOpen

--
Enjoy,
Tony

TedMi said:
I need to open a doc from an Access form. Works fine, except the doc's
AutoOpen does not run. Here's the code:

Dim oWord as Object
Set oWord = GetObject("C:\Data\Merge1.doc")
oWord.Application.Visible = True

This creates a minimized instance of Word with the named doc open. The
prompt to enable/disable macros does appear, but the AutoOpen does not run.
It runs fine when opened from Word File Open or by double clicking its name.
The AutoOpen is in the doc, not normal.dot.

What the Auto does is reset merge data source to an Access file in the local
directory. Any suggestions?
 

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