Visual C++ 7.1Visual Studio .NET 2003Windows 2003Windows 2000Windows XPIntermediateDevVisual StudioWindowsC++
source code to HTML






1.33/5 (14 votes)
Aug 12, 2005

21136
This macro convert cpp source code to HTML code
Introduction
I sometimes need to post my cpp source code to the BBS. Because the BBS removes all html tag and encloses pre tag. I need to do following routine work
- duplicate source code of the selected area
- replace html escape charactors ("<", ">", "&")
- untabify (replace TAB to Equivalent spaces)
So I write a macro for VisualStudio.NET. This is simple but convenient tool for me.
Usage
It's very easy. Select the source code area you want to convert and call this macro. Then converted code was pasted to clipboard.
Code
Sub Src2Html() DTE.UndoContext.Open("ToHTML") Try DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocumentSelection DTE.Find.MatchCase = True DTE.Find.MatchWholeWord = False DTE.Find.MatchInHiddenText = False DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone DTE.Find.Action = vsFindAction.vsFindActionReplaceAll DTE.Find.FindWhat = "&" DTE.Find.ReplaceWith = "&" DTE.Find.Execute() DTE.Find.FindWhat = "<" DTE.Find.ReplaceWith = "<" DTE.Find.Execute() DTE.Find.FindWhat = ">" DTE.Find.ReplaceWith = ">" DTE.Find.Execute() DTE.ActiveDocument.Selection.Untabify() DTE.ActiveDocument.Selection.Copy() Finally DTE.UndoContext.Close() DTE.ActiveDocument.Undo() End Try End Sub