> I am launching Word from an ActiveX control I've written and attempting to
> use an alternative template that contains an AutoNew macro. When I launch
> word, the new document is created based on the alternative template, and I
> get the warning about macro security, but the AutoNew sub is never run.
>
HOW is your activex control "launching" this? Show us the code, please.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
wsprintf(szParameters, "/q /t\"%s\"", szTemplateFileName);
wsprintf(szCommandLine, "%s %s", szWordExe, szParameters); // szWordExe
contains the full path and filename of the WINWORD.EXE executable
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
CreateProcess(NULL, // No module name (use command line).
szCommandLine, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi); // Pointer to PROCESS_INFORMATION structure.
I've also used ShellExecuteEx and achieved the same result -- Word is
launched with a new document based on the supplied template but the AutoNew
macro is not executed.
"Cindy Meister -WordMVP-" <CindyM...@swissonline.ch> wrote in message
news:VA.00008461.00657eaa@speedy...
> I've also used ShellExecuteEx and achieved the same result -- Word is
> launched with a new document based on the supplied template but the AutoNew
> macro is not executed.
>
Yes, what you're encountering is "known and expected" behavior. AutoNew does
not launch when the /t switch is used. That's how it's been since the switch
was introduced, and although it wasn't a factor at the time, given the virus
problems, it's turned out to be a very good thing...
You can launch Word using Shell (or whatever commandline method you wish)
with no problem. But you'll need to actually automate Word (GetObject, or
CreateObject) and use the .Add method to have the template open and execute
the AutoNew macro.