Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening a powerpoint file in VBA (Office XP)

    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):
    <font face="Georgia">
    Dim pp as Powerpoint.Application, pps as Powerpoint.Presentation
    Set pp = New Powerpoint.Application
    Set pps = pp.Presentations.Open("H:My Documentsfilename.pps")
    </font face=georgia>
    ... and get the error shown in the attached screenshot. What am I doing wrong?
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Opening a powerpoint file in VBA (Office XP)

    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.

  3. #3
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a powerpoint file in VBA (Office XP)

    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.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Opening a powerpoint file in VBA (Office XP)

    It is also possible to read built-in document properties without opening the file. See Dsofile.dll lets you edit Office document properties without Office in Visual Basic .NET 2003 and in Visual Basic .NET 2002. (It works in Office VBA too, despite the .NET reference)

  5. #5
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a powerpoint file in VBA (Office XP)

    Excellent! Thanks again, I'll give it a go. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  6. #6
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a powerpoint file in VBA (Office XP)

    Works a dream. It also seems that you can edit the properties using that .dll, too, although I haven't tried that yet. My organisation has just introduced some new rules around file handling, stipulating that the document properties have to be filled in for every document, spreadsheet, etc. - doing it en mass in VBA is going to make life SO much easier. Thanks again, Hans, you're a hero!
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •