Share via


Creating a New Presentation

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

There are two ways you can create a Microsoft® PowerPoint® presentation:

  • By using the Open method of the Application object. You can use any file format recognized by PowerPoint in the Open method's FileName argument. For example, if the FileName argument specifies a Microsoft® Word document in outline view, the outline will be converted to a new presentation with a slide representing each paragraph that has the Heading 1 style in the document.

  • By using the Presentations collection's Add method. For example:

    Dim ppApp     As PowerPoint.Application
    Dim prsPres   As PowerPoint.Presentation
    
    Set ppApp = New PowerPoint.Application
    With ppApp
       Set prsPres = .Presentations.Add(msoFalse)
       With prsPres
          ' Code here to add and format slides in
          ' the new presentation.
       End With
    End With
    

    Note   The WithWindow argument of the Add and Open methods accepts a Boolean value that specifies whether the Window object that contains the presentation will be visible. (The default is True.) Although the Auto List Members drop-down list for the Add method's WithWindow argument contains five enumerated constants, you should use only the msoTrue or msoFalse constants.

When you use Microsoft® Visual Basic® for Applications (VBA) to create a new presentation, it exists in memory, but will not be saved to disk until you use the Presentation object's SaveAs method. (Use the Save method to save changes to a presentation that has already been saved to disk.) The following procedure creates a new Presentation object and immediately saves the presentation by using the name supplied in the strPresName argument. It then returns the new Presentation object to the calling procedure.

Function PPTCreatePresentation(ppApp As PowerPoint.Application, _
                               strPresName As String) As PowerPoint.Presentation
   ' This procedure illustrates how to use the SaveAs method to
   ' save a new presentation as soon as it is created.
   ' Note that in this example, the new Presentation object
   ' is not visible.
   
   On Error GoTo PPTCreate_Err
   
   Set PPTCreatePresentation = ppApp.Presentations.Add(msoFalse)
   If InStr(strPresName, "\") = 0 Then
      strPresName = "c:\" & strPresName
   End If
   PPTCreatePresentation.SaveAs strPresName
PPTCreate_End:
   Exit Function
PPTCreate_Err:
   Select Case Err
      Case Err <> 0
         Set PPTCreatePresentation = Nothing
   End Select
   Resume PPTCreate_End:
End Function

See Also

Working with the Presentation Object | Working with Open Presentations | Working with Existing Presentations | Formatting a Presentation | Running a Slide Show from a Presentation