Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a text file and apply a template to it.

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I am running Word 2003. I have a DOS application from which I wish to open up a text file which I have created in Word.

If I key in :
winword.exe myfile.txt
. . . that opens up the text file in Word and I can edit, save or print it &c

I would however like to set the margins and the font size, and to that end I have defined a template, mytemplate.dot with a macro, mymacro.

If I then key in :
winword.exe /tmytemplate /mmymacro
. . . this does indeed open up a blank document with the appropriate margins, and I can see that the macro is available during the session.

If however I key in :
winword.exe myfile.txt /tmytemplate /mmymacro
. . . this certainly opens myfile.txt, but it is not using mytemplate, and so cannot apply the macro. Altering the sequence of parameters makes no difference.

The only way that I can get the macro to run appears to be if I put it into the normal.dot template, and then key in :
winword.exe /mmymacro

However I would prefer not to have to modify the normal.dot template. Is there a way that I can open a text file from the command prompt, and make available the macros from my own template, then call that macro so that the document appears on the screen as required?

Thanks. Andrew Mozley

 
Have you tried any variations of:
winword.exe /tmytemplate /mmymacro /t myfile.txt ?

Canadian eh! Check out the new social forum Tek-Tips in Canada.
I thought I had retired...I was mistaken. I used to work for a large corporation; now I work for my wife.
 
Thanks xlh

Sadly the command :
winword.exe /tmytemplate /mmymacro /t myfile.txt

. . . has the same effect. That is : it displays myfile.txt, but does not have any of the macros from mytemplate.dot enabled. Did it work differently when you tried it out?

If anyone out there has been able to activate WORD macros (other than those stored in normal.dot) from the DOS prompt I would be very grateful to hear.

Andrew
 
No idea if you tried variations on the switches....that is
[red]winword.exe /t myfile.txt /tmytemplate /mmymacro[/red]

Canadian eh! Check out the new social forum Tek-Tips in Canada.
I thought I had retired...I was mistaken. I used to work for a large corporation; now I work for my wife.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top