Cha*_*ell 4 macros visual-studio
我有一个我运行的宏,它为我的文档写了一个版权标题.当前写入标题时,光标留在标题的末尾.
我希望能够捕获当前位置,写入标题,然后将光标返回到原始位置.
有谁知道如何实现这一目标?
我想我已经明白了.
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)
Run Code Online (Sandbox Code Playgroud)
这都嵌套在我编写的宏中,以自动为每个代码文件添加版权标题.
| 归档时间: |
|
| 查看次数: |
1412 次 |
| 最近记录: |