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

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

posted @   dudu  阅读(746)  评论(0编辑  收藏  举报
编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
点击右上角即可分享
微信分享提示