Here are the steps:

  • Write the code in vs.net
  • 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 Normal.dot template.
Then assign it a keyboard shortcut using right click on toolbars-customize-keyboard-macros and you're done:
 

Sub FormatCodeForBlog()

    Selection.PasteAndFormat(wdPasteDefault)

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

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

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

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

        False)

    ActiveWindow.View.Type = wdWebView

    ActiveWindow.Close()

    RecentFiles(1).Open()

    Selection.WholeStory()

    Selection.Copy()

End Sub

From: http://weblogs.asp.net/rosherove/archive/2004/02/05/67957.aspx

相关文章:

  • 2021-12-31
  • 2021-07-11
  • 2022-12-23
  • 2021-07-16
  • 2021-09-08
  • 2021-12-21
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-07-01
  • 2021-04-22
  • 2021-12-26
  • 2021-10-29
相关资源
相似解决方案