Formatted code in Word using Emacs

Sometimes I have to write some documentation using Word instead of LaTeX. In LaTeX you have some nice options for typesetting code be it R, Stata or Gams. In Word, however, there is no easy way to format your code. I found a nice way to get my code nicely formatted (in color) using Emacs: I installed the Windows version of Emacs and there I can “Quick Print” – “Preview with Web Browser”. This opens the file as htm in my browser. I now just save this file somewhere on my computer and open it in Word. The text is nicely formatted.
For example some R-Code would look like this in Word:

Set the repository for R

Every time you install a R package, you are asked which repository R should use.
To set the repository and avoid having to specify this at every package install, create a file .Rprofile in your home directory with the following text:
       myrepo = getOption(“repos”)
       myrepo[“CRAN”] = “http://stat.ethz.ch/CRAN/
       options(repos = myrepo)
       rm(myrepo)