Click here to Skip to main content
15,893,564 members
Articles / Visual Studio
Alternative
Tip/Trick

Making F1 do something useful in Visual Studio

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
14 Feb 2011CPOL 4.7K  
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:

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --