Knitr -> MS Word

Using R Markdown and "Knit to Word" I became aware that with this combination I can keep the Word document open, side by side with RStudio, and when I change the markdown source file and knit again, it is updated in Word in real time.

How do you do this? Is there a way to use this feature outside of RStudio? I would like to change the XML and show the result in Word as I change the file.

So to the best of my knowledge, knitr (really, pandoc) is simply overwriting the old document with a new one every time you knit. It’s interesting and to Word’s credit that it picks up the new underlying file, but I think that’s entirely on the Word side and nothing to do with RStudio or knitr.

If I’m understanding you correctly, you’d like to have the same docx file open simultaneously in both Word and in some sort of XML editor or text editor and make changes to the XML? That would not be quite the same scenario, and it might be ok or it might be disastrous — I think you’d need to carefully test it to find out.

On Windows, when the docx file is opened by Word, it is blocked. While open, it can't be overwritten, deleted or moved to some other location. It's different on Linux. There you can just overwrite files that are currently opened by some application.

In conclusion, it is the fact that RStudio finds a way around the blocking/locking of Word files on Windows that puzzles me.