OLEObject → Object

PowerPointApplication Class

Used to automate Microsoft PowerPoint.

# Notes

The language that you use to automate Microsoft Office applications is documented by Microsoft and numerous third-party books on Visual Basic for Applications (VBA). Microsoft Office applications provide online help for VBA. To access the online help, choose Macros from the Tools Menu of your MS Office application, and then choose Visual Basic Editor from the Macros submenu. When the Visual Basic editor appears, choose Microsoft Visual Basic Help from the Help menu. The help is contextual in the sense that it provides information on automating the Office application from which you launched the Visual Basic editor.

If VBA Help does not appear, you will need to install the help files. Windows Office 2003 prompts you to install the VBA help files when you first request VBA help. You don't need the master CD. On Macintosh, Office v.X does not install the VBA help files as part of the full install. Quit out of Office and locate your master CD. Open the "Value Pack" folder and double-click the Value Pack installer. In the Value Pack installer dialog, scroll down to the Programmability topic, select it, and click Continue. The installer will then add the VBA help files and examples to your Office installation. When the install finishes, the VBA help files will be available to the Visual Basic editor within all your Office X applications.

Microsoft has additional information on VBA at http://msdn.microsoft.com/vbasic/ and have published their own language references on VBA. One of several third-party books on VBA is "VB & VBA in a Nutshell: The Language" by Paul Lomax (ISBN: 1-56592-358-8).

# Example

This example creates a PowerPoint document with a title page and a user-selected image. The code is in the Action event handler of a Pushbutton. When the user clicks the button he is prompted to select a picture. The picture is then used a a graphic on the title page of the presentation.

Dim ppApp as PowerPointApplication
Dim ppPres as PowerPointPresentation
Dim ppSlide1 as PowerPointSlide
Dim cTop, cWidth, cHeight, cLeft as Single
Dim f as FolderItem
f = GetOpenFolderItem("????")
if f = Nil then
MsgBox "Please select a picture"
else
ppApp = New PowerPointApplication
ppApp.Visible = 1
ppPres = ppApp.Presentations.Add
ppSlide1 = ppPres.Slides.Add(1, 1)
ppSlide1.Shapes.Item(1).TextFrame.TextRange.Text = "My first slide"
ppSlide1.Shapes.Item(2).TextFrame.TextRange.Text = ""
ppSlide1.Shapes.Item(2).Fill.UserPicture f.absolutepath
ppApp.Activate
end if
Exception err as OLEException
MsgBox err.message

# See Also

ExcelApplication, Office, OLEException, OLEObject, WordApplication classes.