Results 1 to 4 of 4
  1. #1
    jjbarry
    Guest

    Excel and PowerPoint Question (English/Excel 2000)

    I am trying to control PowerPoint from an Excel Macro. I want to open an excel file, copy a graph then turn on PowerPoint paste in the graph and then save the PowerPoint file. All of this works fine. However, I then want to close the presentation - which also works - but then I want to quit out of PowerPoint and that is where I am having trouble. Any thoughts? My code is presented below.

    Dim PPT As Object
    Dim PRES As Object

    Workbooks.Open Filename:= "C:"Y_Final.xls"
    ActiveChart.ChartArea.Select
    ActiveChart.ChartArea.Copy

    Set PPT = CreateObject("PowerPoint.Application")
    PPT.Visible = True
    Set PRES = PPT.Presentations.Open("C:Presentation1.ppt")
    PPT.ActiveWindow.View.Paste

    With PPT.ActivePresentation
    PPT.ActivePresentation.SaveAs _
    Filename:="C:My PPTsY_Final.ppt"
    .Close
    End With

    PPT.Quit
    Set PPT = Nothing

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel and PowerPoint Question (English/Excel 2000)

    Well...

    What's the error? Your code works fine for me (I stripped out the Excel select and copy and just pasted whatever was in my clipboard). Worked fine.

    However, I would point out a couple minor things:

    You declare PRES, but never really use it except to open the .ppt. Instead of

    With PPT.ActivePresentation

    use

    With PRES
    .SaveAs Filename:="bla bla"
    .close
    end with

    You might want to set PRES = nothing too.

    Are you trying to present PPT to the user to make changes, etc.? If so, could the user be exiting PPT? Your code would be trying to do the same and you'll get a nice ugly error dialog.

    Maybe you could explain the error you are getting...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Excel and PowerPoint Question (English/Excel 2000)

    I have encountered the same thing automating Word from Excel. Even if I never display the application and dutifully close it and set the object variable to nothing, when I hit Ctrl+Alt+Del Winword is still running deep in the bowels of Windows. I think it runs until I exit Excel, but this was a while ago so I don't remember exactly.

    Solution was to set a reference to the object library under Tools References and use

    Dim wrdApp as Word.Application

    rather than using CreateObject. Don't know why, but it worked for me. Hope it works for PPT, too.

  5. #4
    jjbarry
    Guest

    Re: Excel and PowerPoint Question (English/Excel 2000)

    Thanks for your help. It seems that after some more work with the do-loop that this code was part of it works as is. I thought that the part I posted was the reason for the macro not working, however, it seems to have been the do-loop - Sorry about that.

Posting Permissions

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