Tuesday, May 18, 2010

Pre and Post pend Text to String

Sub preNPost()

' pre and post pend text to a line

Dim StartLine, EndLine, CurrentLine

StartLine = DTE.ActiveDocument.Selection.TopLine
DTE.ActiveDocument.Selection.EndOfDocument(True)
EndLine = DTE.ActiveDocument.Selection.BottomLine
DTE.ActiveDocument.Selection.StartOfDocument()
CurrentLine = DTE.ActiveDocument.Selection.CurrentLine

While (CurrentLine < EndLine)

DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.Text = "+ zzzz "
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = " yyyy"
DTE.ActiveDocument.Selection.LineDown()
CurrentLine = DTE.ActiveDocument.Selection.CurrentLine

End While

End Sub

No comments: