Google search VS.NET macro

Strange: When I try to “Add Reference” in the macro IDE, its disabled.
?

Got past my “Add Reference” problem as if by magic…
Anyway, I added one more public method to my code, because I love to use Google to search a specific site, especially MSDN:

Public Sub SearchMSDNViaGoogleForSelectedText()
    Dim s As String = ActiveWindowSelection().Trim()
    If s.Length  0 Then
        DTE.ItemOperations.Navigate("a href="http://www.google.com/search?hl=enq=site%3Amsdn.microsoft.com+"http://www.google.com/search?hl=enq=site%3Amsdn.microsoft.com+"/a  _
            System.Web.HttpUtility.UrlEncode(s))
    End If
End Sub

To start in new browser window, I found this works:

Diagnostics.Process.Start(“iexplore.exe”, "a href="http://www.google.com/search?q=“http://www.google.com/search?q=”/a System.Web.HttpUtility.UrlEncode(s))

Cool macro :slight_smile:

Great MACRO… Just love it…

My main motivation for using this macro was that the VS built-in F1 help is so painfully slow. However, after switching to the macro I discovered the msdn2 site is also terribly slow. It seem to take a lot of time filling up its tree view on the left side.
Anyway, I’ll certainly keep a copy of this macro in case Microsoft ever speeds up the msdn2 site…

I found this workaround for the Process.Start error “The requested lookup key was not found in any active activation context.”:

Process process = new Process();
process.StartInfo.FileName = "rundll32.exe";
process.StartInfo.Arguments = "url.dll,FileProtocolHandler \"" + url + "\"";
process.StartInfo.UseShellExecute = true;
process.Start();

It works the same as Richard’s solution, only it will use the default browser, nicer for the Firefox fanboys ;).

Nice! When I switched to Visual Studio 2005 I quickly gave up on the built in help.

I could never quite figure it out, it never seems to do what I expect it to and searching online is much easier and faster.

Microsoft seems to be bent on making every Visual Studio version’s help system worse than the one before it and VS2005 has sunk to new levels of sheer badness and overengineering.

It should be the single most easiest part of the program to use, I can’t fathom what they were thinking.

Thanks!

MSDN Google Search
http://www.google.com/coop/cse?cx=001706605492879182808%3Ayra97xpb_7y

Excellent macro - thanks very much for this. I’m now opening into a new tab in firefox when Alt-F1’ing!

The macro is not working for text selected in the Source view of an ASPX page. It works on all other views and panes. (VS 2005).

It works in VS2008 as well.

Great stuff! I was just thinking of writing such a macro when I found yours! Thank you.

Thanks! Here is another simple search macro that works everywere on Windows, not only on Visual Studio.
/Mark

Sory!! here is the link: http://www.winutilis.net/html/misc/vbs/clpbs.asp

A nice idea. I just wish I could get it to work.

Thank you very much for the nice marco.

Great.

For shared macros, I prefer just fully qualifying the calls rather than requiring an import - more portable:

System.Web.HttpUtility.UrlEncode(s))
vs.
HttpUtility.UrlEncode(s))

Here’s my version, tested in vs2008.

  • I’ve changed it to use an external browser
  • I’ve changed it so it doesn’t affect selected text at all
  • I’ve changed so that if there’s white space to the left, it looks to the right

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module HelpFindInBrowser
Sub HelpFindInBrowser()
Dim s As String = ActiveWindowSelection().Trim()
If s.Length > 0 Then
OpenURL(“http://www.google.com/search?q=” & _
Web.HttpUtility.UrlEncode(s))