• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. PowerPoint Solution Development > Objects, Properties, and Methods

Objects, Properties, and Methods

The Application Object

The Application object represents PowerPoint itself. Much of the work in PowerPoint, though, is addressed at the presentation level. However, it is the Application object that maintains the Presentations collection. For example, the Add method is used to create a new presentation, which becomes a member of the Presentations collection. In Listing 5.1, the Folder Picker dialog box is used to target a directory, then a new presentation is added, aptly named new_presentation.ppt. If the Cancel button is clicked in the File Picker dialog box, then an error occurs and is picked up by the error routine.

Listing 5.1. A new presentation is created and saved

Public Sub new_presentation()
  On Error GoTo err_end
  Dim file_name As String
  Dim dlg As FileDialog
  Set dlg = _
    Application.FileDialog(msoFileDialogFolderPicker)
  dlg.AllowMultiSelect = False
  dlg.Show
  file_name = dlg.SelectedItems(1) & _
    "\new_presentation.ppt"
  Application.Presentations.Add
  ActivePresentation.SaveAs file_name
err_end:
  ' error 5 occurs when Cancel button clicked, so report nothing
  If Err.Number <> 5 Then
    MsgBox Err.Number
  End If
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint