I have lots of Doc IDs as comments in my vb project eg
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
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.
Code:
'see doc#25 for more info
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
- Create a new project
- Select "AddIn" from list of project types
- Add a timer to the form frmAddIn
- set the timer interval to 300
- 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
- Run the addIn project
- Open or Start another project "Standard Exe"
- Click the "add-ins" menu
- Click the "My AddIn" sub menu
- 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.