2010-07-07 33 views

回答

7

我想我已經明白了。

 Dim selection As TextSelection = DTE.ActiveDocument.Selection 
     ''# store the original selection and cursor position 
     Dim topPoint As TextPoint = selection.TopPoint 
     Dim bottomPoint As TextPoint = selection.BottomPoint 
     Dim lTopLine As Long = topPoint.Line 
     Dim lTopColumn As Long = topPoint.LineCharOffset 
     Dim lBottomLine As Long = bottomPoint.Line 
     Dim lBottomColumn As Long = bottomPoint.LineCharOffset() 
     Dim verticalOffset As Integer = 0 

     ''# do a bunch of stuff that adds text to the page 

     ''# Restore cursor to previous position 
     selection.MoveToLineAndOffset(lBottomLine + verticalOffset, lBottomColumn) 
     selection.MoveToLineAndOffset(lTopLine + verticalOffset, lTopColumn, True) 

這是所有嵌套在我寫的自動爲每個代碼文件添加版權標題的宏。