1

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.

1 Answer 1

2

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.

4
  • How would a template be applied to that file?
    – 01es
    Jan 3, 2014 at 13:15
  • Whoops, I seem to have misread that part where you required a template to be applied to the file... Disregard my answer then.
    – Timothy
    Jan 3, 2014 at 13:17
  • However to complement my answer, you might be able to use information from the following page to attach the template after the file has been created (using a macro): wordribbon.tips.net/…
    – Timothy
    Jan 3, 2014 at 13:33
  • Unfortunately, the described approach requires a modification of the Normal.dotx, which is not an option in my case.
    – 01es
    Jan 9, 2014 at 7:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .