The Microsoft PowerPoint 97 and 2000 Viewers support a limited Automation model that developers can use to programmatically start a slide show. This article provides general information about using Automation to control the PowerPoint Viewer, and details some of the known problems and restrictions when using the viewer.
To automate the PowerPoint Viewer on a client system, the viewer must be installed and run at least once to properly register the application as an Automation server. To download and install the viewer, clients can go to the following Microsoft Web site and obtain a copy of the PowerPoint Viewer:
To automate the viewer and start a slide show, you create an instance of the PowerPointViewer.Application
object, and then call the NewShow
method, passing a path to the presentation file to start. For example, you could use the following Visual Basic code to start and then stop a new presentation in the viewer:
Private Sub Command1_Click() ' Set a reference to the Microsoft PowerPointViewer 8.0 Object Library ' (msppt8vr.olb) from the Project|References dialog. Dim oPPTViewer As PowerPointViewer.Application Dim oPPTShow As PowerPointViewer.SlideShowView Dim sPPTFile As String ' Choose a PowerPoint file to open... sPPTFile = "C:\DsTest.ppt" ' Start an instance of the viewer. This may fail if the viewer is ' already running. You can use GetObject to get the running viewer, ' however you cannot open a new slide show if another show is in ' progress. So, if this fails, we can't continue. Set oPPTViewer = CreateObject("PowerPointViewer.Application") ' Start the show and get a SlideShowView object... Set oPPTShow = oPPTViewer.NewShow(sPPTFile, _ ppViewerSlideShowManualAdvance, True) ' Display the number of slides in this view... MsgBox "Slides in this show = " & Str(oPPTShow.SlidesCount), _ vbMsgBoxSetForeground ' Exit the slide show and quit (just to demo you can do this)... oPPTShow.Exit Set oPPTShow = Nothing oPPTViewer.Quit Set oPPTViewer = Nothing End Sub
Automation clients should be aware that the type library for the PowerPoint Viewer contains an internal reference to the Microsoft Office 8.0 Object Library, which typically is not available unless Office 97, Office 2000 (mso97.dll/mso9.dll), or the Office run-time file (mso97rt.dll) is installed on the system. Because of this dependency, Automation clients may get the one of the following run-time error messages on a call to CreateObject
, or CoCreateInstance
Run-time error '48': Error loading DLL.
0x80029C4A (TYPE_E_CANTLOADLIBRARY): Error loading type library/DLL.
In order to resolve this error message, at least one Office-compatible application needs to be installed on the system. Besides any Office 97or Office 2000 application, this would include the Microsoft Access 97 or Microsoft Access 2000 run-time, Microsoft Visual Studio, Microsoft Works, and Microsoft ActiveX Control Pad.If you want to run the PowerPoint Viewer from a CD-ROM, you cannot use Automation to start the viewer. Automation requires the viewer to be properly installed and run once (for registration) before you can have COM create a new instance. For additional information on using the PowerPoint Viewer from a CD-ROM, click the article number below to view the article in the Microsoft Knowledge Base:
PPT2000: How to Distribute Presentations on CD-ROM
Instead of Automation, developers may choose to shell a PowerPoint file (*.ppt) to start a slide show and let it run. In addition, the PowerPoint viewer supports the use of a list file (*.lst) to allow for the playing of multiple presentations, one right after the other. For additional information about using a list file, click the article number below to view the article in the Microsoft Knowledge Base:
PPT97: How to Write and Use a List File in PowerPoint Viewer
When viewing a presentation in the viewer, developers should take into consideration that there are other limitations that could affect their design, such as:
- not being able to run Visual Basic for Applications (VBA) macros in the presentation
- not being able to use hyperlinks with grouped objects
- not playing animated Graphics Interface Format (.gif) files
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
PPT2000: Animated GIF Images Don't Work in the Viewer
PPT97: NewShow Method Doesn't Start Slide Show If Viewer Running
PPT97: Viewer Quit Method Does Not Close Viewer