开发者

Visual Studio Macro - Read first X lines instead of entire document

I've got a macro that updates a copyright header with the most recent edit date.

The problem I have is that the macro currently reads through the entire file rather than just the first 6 lines (which is all it needs).

Is there a way to get the Macro to only read the first "X" lines rather than the entire file?

Private selection As EnvDTE.TextSelection = DTE.Act开发者_如何学PythoniveDocument.Selection
Private Sub UpdateCopyrightHeader()

    selection.StartOfDocument()
    selection.EndOfDocument(True)

    Dim content As String = selection.Text
    Dim result = System.Text.RegularExpressions.Regex.Replace(content, regex, "<lastedit>" & FormatDateTime(Date.Now, vbLongDate) & "</lastedit>")

    selection.Delete()
    selection.Collapse()
    Dim ed As EditPoint = selection.TopPoint.CreateEditPoint()
    ed.Insert(result)

End Sub


You need to call LineDown instead ofselection.EndOfDocument(True):

selection.StartOfDocument()
selection.LineDown(True, 6)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜