views:

59

answers:

1

How can I read text of a current line (where cursor is situated) from Macros?

I'm going to use such a function:

 Public Sub AddTextToChangeLogFile()
    Dim textOnACurrentLine As ???
    textOnACurrentLine = ???

    If textOnACurrentLine.Text <> String.Empty Then
        Dim sw As New StreamWriter("C:\###\Changes.txt", True)
        sw.WriteLine(textOnACurrentLine + ". file: " + DTE.ActiveDocument.Name)
        sw.Close()
    End If
End Sub
A: 

You can use something like:

Dim textOnACurrentLine As String
DTE.ActiveDocument.Selection.StartOfLine(0)
DTE.ActiveDocument.Selection.EndOfLine(True)
textOnACurrentLine = DTE.ActiveDocument.Selection.Text
Brian Schmitt
Great idea! Works fine
Vadim