65.9K
CodeProject is changing. Read more.
Home

Making F1 do something useful in Visual Studio

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Feb 14, 2011

CPOL
viewsIcon

4862

I tried to run this the first time without any documents open and it threw an error, so I made a small mod to the original code to prevent VS from whining at me under those, probably limited, circumstances:Dim url As String = "www.google.com/search?q=MSDN"If DTE.ActiveDocument IsNot...

I tried to run this the first time without any documents open and it threw an error, so I made a small mod to the original code to prevent VS from whining at me under those, probably limited, circumstances:
Dim url As String = "www.google.com/search?q=MSDN"
If DTE.ActiveDocument IsNot Nothing Then
    Dim searchFor As TextSelection = DTE.ActiveDocument.Selection()
    If searchFor.Text <> "" Then
        url = "www.google.com/search?q=MSDN+" + searchFor.Text
    Else
        url = "www.google.com/search?q=MSDN"
    End If
End If
DTE.ExecuteCommand("View.URL", url)
I also like the idea of having it open in my browser rather than a new window in VS. :thumbsup: HmCody