0


I have a customised template file in ms word 2010 with windows 7. When I use the following command file > new > my templates > foo to launch the template file,
I am able to launch the file multiple times to generate file1, file2, file3.
When I use a batch file to launch the template file from my desktop, I am only able to generate one file at a time file1.To launch a second time gives an error that the file is already in use. The question is , how can I use the batch file to produce multiple copies of the template file. Below is the code from the template file.

@ech off
@echo welcome
pause
START C:\Users\Faisal\AppData\Roaming\Microsoft\Templates\Dtp_Template.dotm

pause
faisal abdulai
  • 3,739
  • 8
  • 44
  • 66

1 Answers1

0

Assuming this code executes on the command-line the way Word would interpret it you're opening the actual template file. Then it is "of course", in use and cannot be opened again.

What you need is the command line switch to generate a new file from a specified template, which BTW will start the Word application. You need either of the following two switches:

/ttemplatename
/ztemplatename

You'll notice that the full template path follows the switch immediately - no spaces or punctuation.

More information on command line switches for Word can be found at: https://support.microsoft.com/en-us/kb/210565

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
  • Just used the suggestion but i get the error invalid switch.. I present the error below Invalid switch - "/t'C:\Users\Faisal\AppData\Roaming\Microsoft\Templates\Dtp_Tem plate.dotm'". Press any key to continue . . . – faisal abdulai Nov 09 '15 at 22:25
  • As I said in my original reply: do NOT use any punctuation. You have 'apostrophes' around the file name. Remove them. – Cindy Meister Nov 09 '15 at 22:37
  • When I delete the punctuation i still get the same error. This is the switch and code. @START /tC:\Users\Faisal\AppData\Roaming\Microsoft\Templates\Dtp_Template.dotm – faisal abdulai Nov 09 '15 at 22:46
  • You need to point to / use the full path to WinWord.exe in order to use the switch. Also, I believe your START syntax may be incorrect. It appears you need to place the entire command in double-quotes and the command should not be the first parameter. See the information on using the command with parameters in this SO post: http://stackoverflow.com/questions/154075/using-the-dos-start-command-with-parameters-passed-to-the-started-program – Cindy Meister Nov 09 '15 at 23:10