Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Making F1 do something useful in Visual Studio

0.00/5 (No votes)
14 Feb 2011 1  
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=MSDNIf 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:

VB
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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here