Closed Thread
Results 1 to 6 of 6

Open Powerpoint Presentation via Excel VBA code

  1. #1
    hurlbut777
    Guest

    Open Powerpoint Presentation via Excel VBA code

    I have an excel macro in which I would like to open a powerpoint presentation
    based upon a selection made in a drop-down box. The code I have so far is
    below, I just don't know how to tell excel how to open the presentation.
    Thanks.

    Private Sub Business_Plan_Change()
    Workbooks.Open Filename:="F:\Reports\" & Business_Plan.Value & ".ppt"
    End Sub

  2. #2
    Andy Tischaefer [MSFT]
    Guest

    Re: Open Powerpoint Presentation via Excel VBA code

    It looks as though the code you have below is trying to open a PPT file in
    Excel. From what you've written, I don't think that's what you actually
    want to do.

    To open a PPT presentation by running code in Excel, you need to do four
    things - add a reference to the powerpoint object model, boot powerpoint,
    make powerpoint visible, and then open the file you want.

    To add the reference:
    Open VBE (Alt F11)
    Tools / References
    Scan down for "Microsoft Powerpoint <version> Object Library"
    Check the box
    Click OK

    Once you've added the reference, the following code should do what you want:

    Private Sub Business_Plan_Change()
    Dim PPT As PowerPoint.Application
    Set PPT = New PowerPoint.Application
    PPT.Visible = True
    PPT.Presentations.Open Filename:="F:\Reports\" & Business_Plan.Value &
    ".ppt"
    End Sub

    Hope that helps.

    - Andy Tischaefer
    Test Lead, Microsoft Office

    This posting is provided as is, and confers no rights.

    "hurlbut777" <hurlbut777@discussions.microsoft.com> wrote in message
    news:D7CD2EFB-71B9-4A77-AFC1-D739A2B6987E@microsoft.com...
    >I have an excel macro in which I would like to open a powerpoint
    >presentation
    > based upon a selection made in a drop-down box. The code I have so far is
    > below, I just don't know how to tell excel how to open the presentation.
    > Thanks.
    >
    > Private Sub Business_Plan_Change()
    > Workbooks.Open Filename:="F:\Reports\" & Business_Plan.Value & ".ppt"
    > End Sub




  3. #3
    hurlbut777
    Guest

    Re: Open Powerpoint Presentation via Excel VBA code

    When I follow the prescribed instructions, I get a run-time error
    '-2147467259 (80004005)'; PowerPoint could not open the file

    "Andy Tischaefer [MSFT]" wrote:

    > It looks as though the code you have below is trying to open a PPT file in
    > Excel. From what you've written, I don't think that's what you actually
    > want to do.
    >
    > To open a PPT presentation by running code in Excel, you need to do four
    > things - add a reference to the powerpoint object model, boot powerpoint,
    > make powerpoint visible, and then open the file you want.
    >
    > To add the reference:
    > Open VBE (Alt F11)
    > Tools / References
    > Scan down for "Microsoft Powerpoint <version> Object Library"
    > Check the box
    > Click OK
    >
    > Once you've added the reference, the following code should do what you want:
    >
    > Private Sub Business_Plan_Change()
    > Dim PPT As PowerPoint.Application
    > Set PPT = New PowerPoint.Application
    > PPT.Visible = True
    > PPT.Presentations.Open Filename:="F:\Reports\" & Business_Plan.Value &
    > ".ppt"
    > End Sub
    >
    > Hope that helps.
    >
    > - Andy Tischaefer
    > Test Lead, Microsoft Office
    >
    > This posting is provided as is, and confers no rights.
    >
    > "hurlbut777" <hurlbut777@discussions.microsoft.com> wrote in message
    > news:D7CD2EFB-71B9-4A77-AFC1-D739A2B6987E@microsoft.com...
    > >I have an excel macro in which I would like to open a powerpoint
    > >presentation
    > > based upon a selection made in a drop-down box. The code I have so far is
    > > below, I just don't know how to tell excel how to open the presentation.
    > > Thanks.
    > >
    > > Private Sub Business_Plan_Change()
    > > Workbooks.Open Filename:="F:\Reports\" & Business_Plan.Value & ".ppt"
    > > End Sub

    >
    >
    >


  4. #4
    Andy Tischaefer [MSFT]
    Guest

    Re: Open Powerpoint Presentation via Excel VBA code

    That error indicates that the path you're providing to your powerpoint file
    is not valid. To debug, you might try:

    dim filepath as string
    filepath = "F:\Reports\" & Business_Plan.Value & ".ppt"

    and then verify that filepath is what you expect to be, and that it is
    pointing to a valid file.

    Hope that helps.

    - Andy Tischaefer
    Test Lead, Microsoft Office

    This posting is provided as is, and confers no rights.

    "hurlbut777" <hurlbut777@discussions.microsoft.com> wrote in message
    news:82196349-0A5D-444B-B800-A93BE323B790@microsoft.com...
    > When I follow the prescribed instructions, I get a run-time error
    > '-2147467259 (80004005)'; PowerPoint could not open the file
    >
    > "Andy Tischaefer [MSFT]" wrote:
    >
    >> It looks as though the code you have below is trying to open a PPT file
    >> in
    >> Excel. From what you've written, I don't think that's what you actually
    >> want to do.
    >>
    >> To open a PPT presentation by running code in Excel, you need to do four
    >> things - add a reference to the powerpoint object model, boot powerpoint,
    >> make powerpoint visible, and then open the file you want.
    >>
    >> To add the reference:
    >> Open VBE (Alt F11)
    >> Tools / References
    >> Scan down for "Microsoft Powerpoint <version> Object Library"
    >> Check the box
    >> Click OK
    >>
    >> Once you've added the reference, the following code should do what you
    >> want:
    >>
    >> Private Sub Business_Plan_Change()
    >> Dim PPT As PowerPoint.Application
    >> Set PPT = New PowerPoint.Application
    >> PPT.Visible = True
    >> PPT.Presentations.Open Filename:="F:\Reports\" & Business_Plan.Value
    >> &
    >> ".ppt"
    >> End Sub
    >>
    >> Hope that helps.
    >>
    >> - Andy Tischaefer
    >> Test Lead, Microsoft Office
    >>
    >> This posting is provided as is, and confers no rights.
    >>
    >> "hurlbut777" <hurlbut777@discussions.microsoft.com> wrote in message
    >> news:D7CD2EFB-71B9-4A77-AFC1-D739A2B6987E@microsoft.com...
    >> >I have an excel macro in which I would like to open a powerpoint
    >> >presentation
    >> > based upon a selection made in a drop-down box. The code I have so far
    >> > is
    >> > below, I just don't know how to tell excel how to open the
    >> > presentation.
    >> > Thanks.
    >> >
    >> > Private Sub Business_Plan_Change()
    >> > Workbooks.Open Filename:="F:\Reports\" & Business_Plan.Value & ".ppt"
    >> > End Sub

    >>
    >>
    >>




  5. #5
    Registered User
    Join Date
    01-05-2010
    Location
    New Delhi
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Open Powerpoint Presentation via Excel VBA code

    Hi Andy,

    I have done all the steps you have given below, still facing the issue of Error 429 which says "ActiveX component can't create object". Can you please help.

    Thanks
    Yogesh.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003, 2007, 2010 & 2013
    Posts
    18,690

    Re: Open Powerpoint Presentation via Excel VBA code

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    Don't expect a Guest member, from +5 years ago, to be by any time soon.

    Start your own thread detailing your problem, posting code (using tags) and example file(s) to help us help you.
    Cheers
    Andy
    www.andypope.info

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1