Is it possible to create a new MS Word document based on some template from a command line in such a way that it would be stored automatically into the specified file?
The command below creates a new document based on the specified template.
However, this new document needs to be saved interactively from MS Word.
winword /tc:/tmp/template.dot
What I would like to happen is for a new document to be saved automatically upon creation into the specified file. So, something like the command below where /file
would be a flag that points to the required file, would be do the trick.
winword /tc:/tmp/template.dotx /file c:/tmp/new-document.docx
I could not find any command line flags for MS Word to achieve such behaviour. Perhaps this is not available or I've missed it.
Thank you.
Best Answer
If you just need a new, empty Word document, you could use the following:
echo. 2>"New Document.docx"
All this does is creating an empty file; empty as you echo nothing into it. The file opens properly with Word 2013, haven't tested with other versions. The reason that it opens in Word, is simply because of the file extension.
Note that instead of just the file name, you can use a whole path and name here.
Edit: Alternative that is quite simpler:
copy NUL "New Document.docx"
Simply copy the contents of NUL into the new file. In DOS, NUL is in fact a file/device that always contains nothing.