The past few blog posts that I have made had some code in them, and the formatting was lost. I am using Word 2007 for posting to my blog (like a good corporate citizen), but was just about to give up. The blog posts are really hard to read when you have unformatted code in them.
Today I heard about Colin Coller's CopySourceAsHTML. It adds a context menu item so that when you right-click on source in Visual Studio 2005, it will copy the source as HTML. Then you can paste the source into Word 2007, and you get some semblance of code formatting.
You can control whether you get line numbers or not, override CSS, and a few other cool features. The only shortcoming that I see is that it doesn't seem to support ASPX files yet. This tool is really impressive in that you can copy XML, C++, and J# just as easily as C# or VB.NET. Bravo, Colin!
Here are some results of copying from Visual Studio 2005 using CopySourceAsHTML and pasting into Word 2007.
type="WCFExtensions.MyBehaviorExtension, WCFExtensions, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null"/>
// RealEstate.cpp : main project file.
int main(array<System::String ^> ^args)
* Summary description for Service1.
* Required designer variable.
// This call is required by the Windows.Forms Component Designer.
// TODO: Add any initialization after the InitComponent call
#region Windows Form Designer generated code
* Clean up any resources being used.
void Dispose(boolean disposing)
if (components != null)
* Required method for Designer support - do not modify
* the contents of this method with the code editor.
components = new
* Set things in motion so your service can do its work.
void OnStart(String args)
// TODO: Add code here to start your service.
* Stop this service.
// TODO: Add code here to perform any tear-down necessary to stop your service.