Creating a Presentation from a Word DocumentThis content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Microsoft® PowerPoint® 2002
Microsoft® Word 2002
Summary: Using the solution in this article, you can easily convert your Microsoft Word documents into Microsoft PowerPoint presentations, formatted and ready to show. (5 printed pages)
NoteThe form and code sample for this solution is a modified version of the solution located on the CD (in the folder Samples\Ch05) included with the Microsoft Office 2000 Visual Basic Programmer's Guide, published by Microsoft Press.
Have you ever had a Microsoft® Word document that you needed to convert into a Microsoft® PowerPoint® presentation? Perhaps you've used the Send To Microsoft PowerPoint on Word's File menu. When I use it, I have to spend time applying a template, formatting bullet points, and sometimes deleting blank slides. The solution in this article will save you time converting, formatting, and preparing your presentation.
This solution takes a Word document formatted in Outline View and displays it as a PowerPoint presentation slide show. When a user runs the solution against an open document, the code creates a presentation, assigns a template, and then runs a slide show and displays each slide for a specified number of seconds. To accomplish this, I used a UserForm (frmPresProps.frm) and custom code module (modRunPPtPresentation.bas) to transform the contents of a Word document into a PowerPoint presentation that is ready to show. The UserForm and custom code module are available in the sample download.
NotePlace the UserForm and custom code module inside of a global template or the Normal template and not inside the document with which you want to create the presentation. The code creates a temporary document and then closes it to reopen the original document. When the temporary document closes, the code become unavailable and stops executing.
It is important to set up your document using the Outline View mode. To prepare your document in Word, do the following:
- From the View menu, click Outline.
- Once your document is displayed as an outline, format the headings that you want at the top of each slide as Heading 1, and format the bullet points or paragraphs under each slide heading using styles Heading 2, Heading 3, and so on. You don't need to add the actual bullets to your document. PowerPoint adds these to the presentation automatically.
For an example of how your document should be formatted, see the document named PPTOutline.doc included with the sample download.
Once the document is prepared, you can run the ViewOutlineInPowerPoint macro in the code module. Immediately upon running the macro, the code checks that the document is in Outline View. If the document is not in Outline View, you will receive a message and the code will stop running.
The ViewOutlineInPowerPoint subroutine displays the Presentation Properties UserForm. From the UserForm, you can select the template to apply to the presentation and specify the number of seconds to display each slide. In addition, you can save the slide show (.pps file) that the code creates by selecting the Save resulting slide show check box. The UserForm is shown below. You can also find the UserForm in the sample download.
Figure 1: Presentation Properties Dialog
If you create the UserForm, accept the default settings for all controls except for the following:
Caption Presentation Properties
Caption Save resulting presentation
Caption View Presentation
When the UserForm initializes, the code populates the combo box with a list of PowerPoint templates located in your Presentation Designs folder. The path for the Presentation Designs folder is represented by a constant. If your .pot files are located at a different path, you must specify the path in the PPT_TEMPLATE_PATH constant at the beginning of the UserForm code module.
Although Word's object model provides the PresentIt method that you can use to convert a document into a PowerPoint presentation, I wanted to apply a template to the presentation and animate the shapes on each slide. Then I wanted to show the slide show on my screen. The PresentIt method doesn't allow me to do any of these things except manually inside of PowerPoint after Word has converted the document into a presentation. Therefore, I chose to directly access the PowerPoint 10.0 Object Model. To do this, you will need to add a Reference (Tools menu) to the PowerPoint 10.0 Object Model.
Once you select the template design to apply to the presentation, the code performs several functions:
- Saves the original document.
- Saves a temporary copy of the document.
- Closes the temporary copy and reopens the original.
Before performing these functions, the ScreenUpdating property of the Word Application object is set to False, so the screen doesn't jump around while performing the actions. Once the actions are completed, the ScreenUpdating property is set back to True.
Next, the code calls a custom function called GetRunningPPT. The GetRunningPPT function checks whether PowerPoint is currently running. If it is, the function returns a reference to the PowerPoint application. If PowerPoint isn't currently running, the function returns Nothing. This is so that when the code finishes and closes the PowerPoint presentation, if PowerPoint was running when the code started, the code won't quit PowerPoint as well. Otherwise, the code quits PowerPoint once the show is finished.
After returning a reference to the PowerPoint application, the code performs another series of functions:
- Opens in PowerPoint the temporary copy of the document saved earlier.
- Animates the shapes on each slide.
- Applies the template and slide timing setting as specified in the Presentation Properties form.
- Displays a slide show of the presentation.
To animate the shapes on each slide, I used the Effects object, new to PowerPoint 2002. By creating a custom effect and applying it to each of the shapes, I was able to animate each shape. To accomplish this, I created a nested For…Next loop for each shape on a slide inside of a For…Next loop for each slide in the presentation.
Next, I specified a custom effect using the AddEffect method of the Sequence collection. The AddEffect method requires a Shape object, so I created the Effect object inside the For…Next loop for each Shape object on the slide. This causes the same animation to be applied to each shape on each slide. To make the animation in the slide show appear as if you added custom animation to each shape, I specified the EffectID parameter of the AddEffect method as msoAnimEffectRandomEffects.
Last, I added an after effect so that when the starting animation ends, the animated text will change color. To accomplish this, I set the AfterEffect property of the AnimationSettings object for each shape to ppAfterEffectDim.
After the slide show starts, you can watch the slide show go through to completion or end it prematurely. The following piece of code checks that the presentation slide show is still running and, as long as it is running, allows the performing of any background functions. The following code (which is included in the code for the PresentationView subroutine) allows you to quit the slide show before it finishes. All you need to do is right-click on the running slide show and it ends. Note that if you press the ESC key to end the slide show, the code generates an error.
Do While objCurrentShow.State = ppSlideShowRunning DoEvents Loop
NoteIf this code is not in the subroutine, the slide show closes immediately after it opens. The DoEvents keyword allows the slide show to finish running to completion before closing the presentation, deleting the temporary file, and quitting the application
Finally, when the slide show ends, the code performs a final set of actions:
- Saves the slide show to the same path and name as the original document (removing the .doc extension and adding a .pps extension).
- Closes the presentation without saving it (note that if you did not select to save the presentation earlier, there will be no presentation file to which you can return).
- Quits PowerPoint if it wasn't running when the subroutine started.
- Removes the temporary copy of the document used to create the presentation.
Now you can convert your documents into presentations without reformatting all of the headings and bullets. Who knows what you can do with all of the time and money you save?