Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gfle_wrk - 09 Oct 2006 12:05 GMT
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!
Helmut Weber - 09 Oct 2006 17:05 GMT
Hi,

have you tried the switch
/mMacroname?

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

gfle_wrk - 09 Oct 2006 18:00 GMT
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 :
> Hi,
> have you tried the switch
[quoted text clipped - 4 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 10 Oct 2006 16:38 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.