• Opening a powerpoint file in VBA (Office XP)

    Home » Forums » AskWoody support » Productivity software by function » MS PowerPoint and presentation apps » Opening a powerpoint file in VBA (Office XP)

    Author
    Topic
    #414748

    I must be missing something really obvious here, but can’t find out what! I’m just trying to open a powerpoint file (in this case a slide show, but I get the same error with presentations) using VBA in Excel (this isn’t the exact code I’m using but amounts to the same thing):

    Dim pp as Powerpoint.Application, pps as Powerpoint.Presentation
    Set pp = New Powerpoint.Application
    Set pps = pp.Presentations.Open(“H:My Documentsfilename.pps”)

    … and get the error shown in the attached screenshot. What am I doing wrong?

    Viewing 0 reply threads
    Author
    Replies
    • #922983

      You must either make PowerPoint visible before opening the slide show/presentation:

      Dim pp as Powerpoint.Application, pps as Powerpoint.Presentation
      Set pp = New Powerpoint.Application
      pp.Visible = True
      Set pps = pp.Presentations.Open(“H:My Documentsfilename.pps”)

      or open the slide show/presentation without opening a window:

      Dim pp as Powerpoint.Application, pps as Powerpoint.Presentation
      Set pp = New Powerpoint.Application
      Set pps = pp.Presentations.Open(FileName:=”H:My Documentsfilename.pps”, WithWindow:=False)

      If you open the slide show/presentation without a window, it will be invisible, but available for manipulation in code.

      • #922994

        Thanks, Hans, that’s perfect. I’m only opening the file to read it’s properties (pps.BuiltinDocumentProperties) and then closing it again, so I’ve gone for the second option.

    Viewing 0 reply threads
    Reply To: Opening a powerpoint file in VBA (Office XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: