I have lots of Doc IDs as comments in my vb project eg
Code:
'see doc#25 for more info
And i wanted to be able to quickly show the document.

This code below will show you the selected text and then you can parse it out and respond to any number of things you might find


  1. Create a new project
  2. Select "AddIn" from list of project types
  3. Add a timer to the form frmAddIn
  4. set the timer interval to 300
  5. Add this code to timer1_timer() event


Code:
    
    Dim startLine As Long, startCol As Long
    Dim endLine As Long, endCol As Long
    Dim sContent As String, tmp As String, l As Long
    
    On Error Resume Next
    VBInstance.ActiveCodePane.GetSelection startLine, startCol, endLine, endCol
    On Error GoTo 0

    If startLine <> 0 Then
        For l = startLine To endLine
            tmp = VBInstance.ActiveCodePane.CodeModule.Lines(l, 1)
            If l = endLine Then tmp = Left(tmp, endCol - 1)
            If l = startLine Then tmp = Right(tmp, (Len(tmp) - startCol) + 1)
            sContent = sContent & IIf(Len(sContent) > 0, Chr(10), "") & _
                      tmp
        Next l
    End If
    Debug.Print sContent & "     " & Timer
  1. Run the addIn project
  2. Open or Start another project "Standard Exe"
  3. Click the "add-ins" menu
  4. Click the "My AddIn" sub menu
  5. Open a code window and highlight some code and you will see the highlighted text in the immediate window of the AddIn project


note: I'm also looking for a way to detect what text is under the cursor when hovering over some code. If anyone knows of a way to do this, let me know.