Google from Word

Add a little Google to Microsoft Word.

You probably use Google a few dozen times a day. If you work a lot within Microsoft Word, using Google usually means switching over to your web browser, checking the results, and then going back to Word. This hack will show you how to display the search results in Word’s New Document Task Pane.

This hack uses a plain text .ini file to store data and some Visual Basic for Applications (VBA) code that also uses VBScript regular expressions.

Tip

This hack will work only with Word 2003 for Windows.

Using Google from Word requires a bit of setup, but once you’ve installed the appropriate tools, you can use Google from within any Word macro.

Install the Web Services Toolkit

First, install the free Microsoft Office 2003 Web Services Toolkit 2.01. Search for it on the Microsoft web site (http://www.microsoft.com/downloads/) or Google it.

Create a New Template

Next, create a new template to hold your Google-related macros. The Web Services Toolkit will create some code so that you can work with Google. A separate template will help you keep track of the code. Create a new, blank document and save it as a Document Template named GoogleTools.dot.

Install the Google Interface VBA Code

From your new GoogleTools.dot template, select ToolsMacroVisual Basic Editor. The Web Services Toolkit will have added a new item called Web Service References on the Tools menu, as shown in Figure 5-19.

Figure 5-19. Creating a new reference for accessing Google ...

Get Google Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.