Class

# PowerPointApplication

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to automate Microsoft PowerPoint. Supported on the Windows platform only.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                   | Type                                        | Read-Only | Shared |
|----------------------------------------|---------------------------------------------|-----------|--------|
| `Handle<powerpointapplication.handle>` | `Ptr</api/data_types/additional_types/ptr>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                               | Parameters                                                                                       | Returns                              | Shared |
|----------------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------|--------|
| `Constructor<powerpointapplication.constructor0>`  | copy As `OLEObject</api/windows/oleobject>`                                                      |                                      |        |
| `Constructor<powerpointapplication.constructor1>`  | ProgramID As `String</api/data_types/string>`                                                    |                                      |        |
| `Constructor<powerpointapplication.constructor2>`  | ProgramID As `String</api/data_types/string>`, NewInstance As `Boolean</api/data_types/boolean>` |                                      |        |
| `Invoke<powerpointapplication.invoke>`             | NameOfFunction As `String</api/data_types/string>`                                               | `Variant</api/data_types/variant>`   |        |
| `TypeName<powerpointapplication.typename>`         |                                                                                                  | `String</api/data_types/string>`     |        |
| `Value<powerpointapplication.value>`               | PropertyName As `String</api/data_types/string>`                                                 | `Variant</api/data_types/variant>`   |        |
| `ValueArray<powerpointapplication.valuearray>`     | Name As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>`     | `Variant()</api/data_types/variant>` |        |
| `ValueArray2D<powerpointapplication.valuearray2d>` | Name As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>`     | `Variant()</api/data_types/variant>` |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                   | Parameters                                                                                          | Returns                            |
|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------|------------------------------------|
| `EventTriggered<powerpointapplication.eventtriggered>` | NameOfEvent As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>` | `Variant</api/data_types/variant>` |

## Property descriptions

<div id="powerpointapplication.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> Returns a pointer to the IDispatch interface that is being used.

## Method descriptions

<div id="powerpointapplication.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Constructor

**Constructor**(copy As `OLEObject</api/windows/oleobject>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a copy of the OLEObject.

<div id="powerpointapplication.constructor1">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Constructor

**Constructor**(ProgramID As `String</api/data_types/string>`)

> Creates a new OLEObject using the passed ProgramID is the COM server's program ID as stored in the registry. It can also be the Class ID (in curly braces). This constructor will try to find a previous instance of the COM server if it is running. Otherwise, it will create a new instance.

<div id="powerpointapplication.constructor2">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Constructor

**Constructor**(ProgramID As `String</api/data_types/string>`, NewInstance As `Boolean</api/data_types/boolean>`)

> Creates a new OLEObject using the passed ProgramID is the COM server's program ID as stored in the registry. The NewInstance parameter specifies whether to create a new instance of the COM server (`True</api/language/true>`) or try to use an existing one if it is running (`False</api/language/false>`).
>
> The following example automates Internet Explorer.
>
> ``` xojo
> Try
>   Var obj As OLEObject
>   Var v As Variant
>   Var params(1) As Variant
>
>   obj = New OLEObject("InternetExplorer.Application", True)
>   obj.Value("Visible") = True
>   params(1) = "https://www.xojo.com"
>   v = obj.Invoke("Navigate", params)
> Catch err As OLEException
>     MessageBox(err.Message)
> End try
> ```

<div id="powerpointapplication.invoke">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Invoke

**Invoke**(NameOfFunction As `String</api/data_types/string>`) As `Variant</api/data_types/variant>`

> Invokes a method of the COM server, and passes the array of parameters to the method.
>
> Make sure to correctly dimension the array, as this will determine the number of parameters that get passed to the method. The first parameter begins at 1.

<div id="powerpointapplication.typename">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.TypeName

**TypeName** As `String</api/data_types/string>`

> Returns a `String</api/data_types/string>` that provides `Variant</api/data_types/variant>` subtype information about the object.

<div id="powerpointapplication.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.Value

**Value**(PropertyName As `String</api/data_types/string>`) As `Variant</api/data_types/variant>`

> Used to get or set a value of the object.
>
> The parameter *PropertyName* is the name of the property to assign a new value to or to get the value. The value property can optionally take a list of properties when assigning a value, i.e.,
>
> ``` xojo
> OLEObject.Value(NameOfProperty As String, params() As Variant) = value
> ```
>
> If the optional parameter ByValue is `True</api/language/true>`, property assignment is by value.

<div id="powerpointapplication.valuearray">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.ValueArray

**ValueArray**(Name As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>`) As `Variant()</api/data_types/variant>`

> Used to get or set a value of the object.
>
> The Name parameter is the name of the property to assign a new value to or to get the value. ValueArray can accept a list of parameters to pass to the automation object. The parameters array is assumed to be 1-based.

<div id="powerpointapplication.valuearray2d">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.ValueArray2D

**ValueArray2D**(Name As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>`) As `Variant()</api/data_types/variant>`

> Used to get or set a value of the object for two-dimensional arrays.
>
> The Name parameter is the name of the property to assign a new value to or to get the value. ValueArray2D can accept a list of parameters to pass to the automation object. The *Parameters* array is assumed to be 1-based.

## Event descriptions

<div id="powerpointapplication.eventtriggered">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PowerPointApplication.EventTriggered

**EventTriggered**(NameOfEvent As `String</api/data_types/string>`, Parameters() As `Variant</api/data_types/variant>`) As `Variant</api/data_types/variant>`

> Occurs when the OLEObject receives an event from the automation server. The event name is passed as the first parameter and the parameters for the event are passed as an array of `variants</api/data_types/variant>`.

## Notes

<div class="note">

<div class="title">

Note

</div>

You will need to copy the MSOfficeAutomation plugin (located in the Extras folder of the installation) to the Plugins folder before you can use this class.

</div>

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.

In Office 2007, click the Microsoft Office button and then click Options. Then select Popular and select the Show Developer Tab in the Ribbon checkbox.

You will then see a Visual Basic button in the Code group in the ribbon and menubar now includes a Help menu which leads to the VB online help.

To access the online help in Office 2003, 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.

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).

## Sample code

This code creates a PowerPoint document with a title page that contains a couple of bulleted items. The code is in the Pressed event handler of a DesktopButton.

``` xojo
Var ppApp As New PowerPointApplication
Var ppPres As PowerPointPresentation
Var ppSlide1 As PowerPointSlide
Var ppSlide2 As PowerPointSlide

ppPres = ppApp.Presentations.Add
ppSlide1 = ppPres.Slides.Add(1, Office.ppLayoutText)
ppSlide2 = ppPres.Slides.Add(2, Office.ppLayoutTextAndChart)

ppSlide1.Shapes(1).TextFrame.TextRange.Text = "My first slide"
ppSlide1.Shapes(2).TextFrame.TextRange.Text = "Automating PowerPoint is"_ 
  + " easy!"

ppSlide2.Shapes(1).TextFrame.TextRange.Text = "Slide 2's topic"
ppSlide2.Shapes(2).TextFrame.TextRange.Text = "You can create and use"_
  + " charts in your Powerpoint slides!"

' Setup slide show properties
ppPres.Slides.Range.SlideShowTransition.EntryEffect = Office.ppEffectRandom
ppPres.Slides.Range.SlideShowTransition.AdvanceOnTime = Office.msoTrue
ppPres.Slides.Range.SlideShowTransition.AdvanceTime = 3 ' 3 seconds per slide

' Prepare and run the slide show
ppPres.SlideShowSettings.ShowType = Office.ppShowTypeKiosk
ppPres.SlideShowSettings.LoopUntilStopped = Office.msoTrue

ppPres.SlideShowSettings.RangeType = Office.ppShowAll
ppPres.SlideShowSettings.AdvanceMode = Office.ppSlideShowUseSlideTimings
ppPres.SlideShowSettings.Run

' Sleep 10 seconds so user can watch the show.
Var t As Integer = System.ticks
Do
Loop Until System.Ticks - t > 60 * 10

ppPres.Close

' Clean up.
ppApp.Quit

Exception err As OLEException
  MessageBox(err.Message)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code creates a new PowerPoint document and adds a picture to the first page. The path to the picture should be in the `TextField</api/user_interface/desktop/desktoptextfield>`, PictureField.

``` xojo
Var ppApp As New PowerPointApplication
Var ppPres As PowerPointPresentation
Var ppSlide1 As PowerPointSlide

ppApp.Visible = True
ppPres = ppApp.Presentations.Add
ppSlide1 = ppPres.Slides.Add(1, Office.ppLayoutText)

' PictureField is a TextField that should contain a path to the picture
' to be added to PP title page.

If Not PictureField.Text.IsEmpty Then
  ppSlide1.Shapes.AddPicture(PictureField.Text, False, True, 10, 10)
Else
  MessageBox("Please select a picture.")
End If

Exception err As OLEException
  MessageBox(err.message)
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | Windows               |

<div class="seealso">

`OLEObject</api/windows/oleobject>` parent class; `Controlling Microsoft Office from your app</topics/office_automation/controlling_microsoft_office_from_your_app>`, `ExcelApplication</api/windows/excelapplication>`, `Office</api/windows/office>`, `OLEException</api/exceptions/oleexception>`, `OLEObject</api/windows/oleobject>`, `WordApplication</api/windows/wordapplication>` classes.

- [VBA Programming Language Documentation](http://www.microsoft.com/en-us/download/details.aspx?id=9034)
- [Office Developer Documentation](https://msdn.microsoft.com/en-us/library/office/dn467914.aspx)

</div>
