Pasting nicely formatted code into your blog from Visual Studio.NET

Here are the steps:

  • Write the code in
  • Paste it into a new word document
  • Save the document as an html(filtered) (or .Text will have trouble with it)
  • Close the doc , then re-open it without changing any text after that (this is an important step)
  • Copy the code from the doc into your blog post
Update: ok. This was just too obvious. I've created a short word macro that does this for you.
simply paste the following code in a new macro module in word that belongs to the template.
Then assign it a keyboard shortcut using right click on toolbars-customize-keyboard-macros and you're done:

Sub FormatCodeForBlog()


    ActiveDocument.SaveAs(FileName:="temp.htm", FileFormat:=wdFormatFilteredHTML, _

          LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _

        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _

        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _


    ActiveWindow.View.Type = wdWebView





End Sub


posted @ 2004-02-18 07:16  dudu  阅读(705)  评论(0编辑  收藏  举报