logo logo

Using Google from Microsoft Word

Add a little Google to Microsoft Word.

ms_word1 Using Google from 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.

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 Toolsu2192 Using Google from Microsoft WordMacrou2192 Using Google from Microsoft WordVisual 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

goh2_0519 Using Google from Microsoft Word

Select Toolsu2192 Using Google from Microsoft WordWeb Service References to display the dialog shown in Figure 5-20. Enter google in the Keywords field and click the Search button. When the web service is found, check the box next to it, and click the Add button.

Figure 5-20. Locating the Google search web service

goh2_0520 Using Google from Microsoft Word

When you click the Add button, you’ll notice a flurry of activity on your screen as the Web Services Toolkit installs several new class modules into your template project, as shown in Figure 5-21.

Figure 5-21. The code created by the Web Services Toolkit

goh2_0521 Using Google from Microsoft WordThe Web Services Toolkit creates the code, but it actually comes from Google using Web Services Description Language (WSDL). The Toolkit interprets this information and generates the VBA code needed to access the web service—in this case, Google.

bottom

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

bottom