You are on page 1of 7

How to proof-read your MS Word 2007

documents using text-to-speech

By William Sengdara

Yes, I know that this document should have been posted on a programming forum but I strongly believe that it
will help out some of the writers who submit their little works to and have no time for such forums.

If you work with Adobe PDF documents, you would by now have noticed that the program is able to
read the documents out loud – using the text-to-speech libraries installed on the computer.
Now, the way I do it is that whenever I write a novel, I will print it to a PDF printer and then have
Acrobat Reader read it out loud so that I am able to spot the numerous grammatical mistakes I am
naturally prone to make. As you can imagine, this compose-then-print-then-read cycle is an extreme waste
of time, as well as years spent as a freelance programmer.

Eventually though, I decided to investigate how to make things easier for myself. Comfort – not necessity,
is the mother of invention. Since I’ve worked with text-to-speech numerous times before, the only
problem I envisaged was with the MS Word Document Object Model. The help files that come with
Word helped with that!

So now, I have written a macro in MS Word to read the documents straight from within the program and
hopefully, some of you will give this tutorial a read-through.

This tip may work with previous versions of MS Word, but I have not bothered to check that out.
Creating the MS Word text-to-speech macro

1. Open MS Word 2007. Starts with a blank document. Now type in a few lines for testing purposes.
2. On the toolbar, locate and click the View menu, then click Macros.
3. A submenu will pop down as shown below

5. Click Record Macro… the dialog below will be displayed

6. In the Macro name input box, type ReadOutLoudStarter, as shown above.

7. Click OK to begin recording. You will record nothing - just need VBA editor to create ReadOutLoudStarter.
8. Click the Macros menu in point 3 above again, but this time click Stop Recording.
9. Click the Macros menu again as in point 8 again, but this time click View Macros, to show the list.

10. Now select our new macro ReadOutLoudStarter in the list and click the button on the right named Edit.
11. The Visual Basic for Applications (VBA) editor will now open and allow you to edit the macro.
12. Inside the macro, just add the following lines of code vbModal
12. Look for a folder in the list on your left named Forms, right-click it as shown in the image below and click
Insert -> UserForm.

13. A UserForm will now be added to the forms folder. You must now rename the form to ReadOutLoud and add
one command button from the ToolBox as show below and name it cmdClose. Change its caption to Done
Reading. If desired, you may add the label shown also and just type in The current selected text will now be read
by Speech API.
14. Double-click the button really fast so that the VBA code editor will open inside the button’s subroutine. Inside
the cmdClose_Click, type:
Unload Me
15. Now we need to add the Speech library reference, so on the menu, click Tools -> References as shown below.

16. The References dialog box will be shown. Scroll all the way to the bottom and search for and tick off the
Microsoft Speech Object Library

17. Now that we have the required reference, we must complete the code. Make sure your code is similar to the
code below:
Option Explicit

Dim spEngine As SpeechLib.SpVoice

Private Sub cmdClose_Click()

Unload Me
End Sub

Private Sub UserForm_Initialize()

Set spEngine = New SpeechLib.SpVoice

spEngine.Speak ActiveDocument.ActiveWindow.Selection.Text, SVSFlagsAsync

End Sub

18. Good job! Now close the VBA editor so that you are returned to the MS Word document with your few lines.
One last thing is to create an icon for the macro so that we can call it up any time we need it.
19. Click the large round MS Word button, and then click Word Options.

20. In the Options below, click Customize, click the Choose commands from drop down and click Macros.

21. Select the macro we created named Normal.NewMacros.ReadOutLoud. Click the Add >> button to move it to
the right list.
22. Now click once the macro and click the Modify button, in order for us to choose an icon and rename the
macro to a shorter name.
23. The modify button window will now open up. I selected the smiley face icon. Then I changed the display name
value to something much shorter, ReadOutLoudStarter.
24. Click OK to accept the changes.
25. If you have followed through correctly, the top of your MS Word toolbar should now look something like this,
with our macro icon ready for action.

26. Finally to test this thing out!

27. Select some text in your MS Word document and then click the smiley face icon to start the proof-reading by
the text-to-speech macro. Click the Done Reading button to close the dialog as required.