none
add PowerPoint presentation title using Excel VBA RRS feed

  • Question

  • Hi,

    I have a code to create a new PowerPoint presentation with slides. Everything works.

    Code:

    Sub FleetPerformance()
     
    Dim ApplPP As Object
    Dim PrsntPP As Object
    Dim SlidePP As Object
    Dim ShapePP As Object
        
        'Defining Sheet names
        Set WB = ThisWorkbook
        Set WSFleetPerfTwo = WB.Worksheets(8)
        Set WSFleetPerfOne = WB.Worksheets(7)
        
        'Create a new instance of the PowerPoint application, if an existing PowerPoint object is not available.
        'Set the Application object as follows:
        On Error Resume Next
        
        Set ApplPP = GetObject(, "PowerPoint.Application")
        
        'If an instance of an existing PowerPoint object is not available, an error will occur (Err.Number = 0 means no error)
        If Err.Number <> 0 Then
            Set ApplPP = CreateObject("PowerPoint.Application")
        End If
        
        'Disable error handling
        On Error GoTo 0
        
        'PowerPoint window visible
        ApplPP.Visible = True
        
        'Create a new presentation in PowerPoint
        Set PrsntPP = ApplPP.Presentations.Add

    Now I want to set the filename of the presentation. So when, and if, someone wants to save it, the right filename should already be available. 

    Is there a way to build this?

    Thanks in advance!

    Monday, October 31, 2016 6:31 PM

Answers

  • Hi,

    According to Presentation.Name Property (PowerPoint):

    The name of the presentation includes the file name extension (for file types that are registered) but doesn't include its path. You cannot use this property to set the name. Use the SaveAs method to save the presentation under a different name if you need to change the name. Read-only.

     

    So we are unable to use Name property to set the filename. For a new presentation, we can only use Presentation.SaveAs Method (PowerPoint) to save with the new name.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ganeshgebhard Tuesday, November 1, 2016 11:01 AM
    Tuesday, November 1, 2016 1:49 AM
    Moderator