Hack 61. Redirect Help to Google![]() help by hooking up a macro to Google and other search engines.[Hack #60], you saw a way to highlight text and then query a search engine using that selected text. This hack is similar in that it allows you to select text and then search Google with that text. The difference between these hacks is that this hack uses a macro. This makes it easier to wire up to a shortcut key and to change the search engine to use.The first step to using this macro is creating a managed class to interact with from the macro. Here is the process to do this:Open the Visual Studio .NET 2003 command prompt under Start Visual Studio .NET Tools.Enter the following command into the command prompt: tlbimp %SystemRoot%\system32\shdocvw.dll /out:"%VSINSTALLDIR%\PublicAssembliesInterop.hdocvw.dll"Next, you will need to create the actual macrofor detailed instructions on how to create macros, please refer to [Hack #51] :Add a reference to your macro project to the Interop.SHDocVW assembly, which will be listed under the .NET tab.Add a reference to the System.Web assembly.Add the following line of code to the top of your module: Imports InteropAdd the following code to the body of your module: Sub DoGoogleSearch( )The next step is to add a shortcut key or toolbar item for your macro. For information on performing either of these actions, please refer to [Hack #51].Once your macro is created and accessible, you will be able to select a bit of text and then press your shortcut key (I like to assign Alt-F1 for this macro), and you will be shown a search results screen for that bit of code, as shown in Figure 7-13. Figure 7-13. Google help![]() change which search engine this macro uses. If you wanted to create a macro to search Google groups instead of Google web, you would simply need to copy this macro and change the following line from: Dim url As String = _to the following: Dim url As String = _As you can see from this example, it would be very simple to change this to any online resource that has a predictable query string format.Thanks to Marty Garins for writing this macro and posting it on his web log, which can be found http://www.little-garins.com/Blogs/marty. |