How to launch a macro from a .dot with a command line

G

gfle_wrk

Hi everyone,
First of all, sorry for my English.
Here is my problem.

I have created (Word 2000) a template myModel.dot with code in it. I
want this code to be launched every time I create a Word document based
on this template.
I create my word document with that command line : "...\WINWORD.EXE"
/t"...\myModel.dot". This creates a new Word document based on my
template... but no code is launched!

I put the code in the macro AutoNew and in the procedure Document_New.
Nothing works.
I have tried "...\WINWORD.EXE" /z"...\myModel.dot". Doesn't work
either.

Can you help me, please?

Thanks a lot!
 
H

Helmut Weber

Hi,

have you tried the switch
/mMacroname?

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
G

gfle_wrk

Hallo Helmut,
Danke for your answer. ;-)

And my answer to your question would be : I've tried, and nothing
worked. But maybe I don't write my command line right. I have tried :
1- "...\WINWORD.EXE" /t"...\myModel.dot"/mMyMacro,
2- "...\WINWORD.EXE" /mMyMacro /t"...\myModel.dot"
3- "...\WINWORD.EXE" /mMyMacro/t"...\myModel.dot"
4- "...\WINWORD.EXE" "...\myModel.dot"/mMyMacro
Nothing seems to work....

The thing that is killing me is that my AutoOpen macro and my
Document_New procedure are launched correctly when I open myModel.dot
directly from the explorer. But when I try with the command line, it
doesn't.
I have looked at the command line used by Windows to open a .DOT file
(Explorer-Tools-Folder options). Apparently, it uses some DDE interface
(DDE message used : [REM_DDE_Direct][FileNew("%1")]), but I don't know
how to use this interface in my command line... And I can't find
anything about this on the Internet.

So if someone has a tip for me... Thanks again.

Greetings from Paris, France.


Helmut Weber a écrit :
 
H

Helmut Weber

Hi,

as seemably nobody else knows better ;-)

i've often encountered problems with automacros.

It seems to be a matter of timing
and of the sequence in which dots are loaded.

The following works for me:
winword /tc:\edit2003\co-english.dot

Of course, cmd is in the appropriate directy already.

Creates a new doc from the template "co-english.dot".

In normal.dot:
Sub AutoExec()
' not working with autonew, it seems
' wait 6 seconds
Application.OnTime When:=Now + TimeValue("00:00:06"), _
Name:="AutoNewtest"
End Sub

In the template "co-english.dot"

Sub AutoNewtest()
MsgBox "Autonewtest from co-english.dot"
End Sub


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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