Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Excel Charts to Powerpoint

Status
Not open for further replies.
Sep 20, 2009
3
US
I am using Excel 2007 and Powerpoint 2007
I have an Excel Worbook called Book1 ("C:\book1.xslm") . It has 5 charts on worksheet "Sheet1"
The charts are Chart 1, Chart 2, Chart 3,Chart 4 and Chart 5.

I need to transfer 5 charts on to a Powerpoint presentation,
"C:\Presentation.ppt" . The " Chart 1" and "Chart 2" have to be transferred to Slide 1 of Powerpoint Application C:\Presentation.ppt.
Chart 3 and Chart 4 should be transferred to Slide 2 of the powerpoint presentation
Chart 5 Should be transferred to Slide 3 of the powerpoint presentation

Could some one please suggest the necessary VBA code in MS Excel 2007 as to how I can transfer the 5 charts from Excel to Powerpoint

Thanks
 


Hi,

Turn on your macro recorder and record the process of copying ONE of your charts to the .ppt.

Post back with your recorded code.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Now Then

This works in Office 2000. It might need some tweeks to select your charts and display them how you want them, but it its a good starting point

Code:
Public Sub test()
 
    '---------------------------
    ' Creates the PowerPoint Object
    '---------------------------
    ' Remember to reference powerpoint from Excel
    Dim objPPT As Object                    ' Object to contain Powerpoint App
    Dim pPresentation As PowerPoint.Presentation  ' Presentation file
    Dim pSlide As PowerPoint.Slide         ' A powerpoint slide

    Set objPPT = CreateObject("Powerpoint.Application")
    
    ' Show the powerpoint file.
    objPPT.Visible = True
    
    ' Create a new presentation
    Set pPresentation = objPPT.Presentations.Add 'Adds a blank presentation
    
    ' Add the key
    pPresentation.slides.Add pPresentation.slides.Count + 1, ppLayoutBlank
        
    Set pSlide = pPresentation.slides(pPresentation.slides.Count)
            
    Chart2.ChartArea.Copy
    
    pSlide.Shapes.Paste
    
    With pSlide.Shapes(1)
        .Top = 20
        .Left = 20
        .LockAspectRatio = msoFalse
    End With
    
    'clears the object variable
    Set objPPT = Nothing 'This does not close the application
    

End Sub
 
Thanks for your suggestion.

This definetly pastes the chart from Excel to Powerpoint
But, every time a new Powerpoint application is created.

But I already have a fixed powerpoint file called
C:\Presentation.pptx.

I should always open that particular file and should copy the Excel charts into the fixed slides as I had described earlier.

Could you kindly suggest as to how to open an existing powerpoint application instead of creating a new powerpoint application.

Thanks


 


you could have figured part of this out by turning on your macro recorder in PP and recording OPENING this pres...
Code:
    ' Create a new presentation
    Set pPresentation = objPPT.Presentations.OPEN("C:\Presentation.pptx") opens presentation
This is why I initially suggested. Learn to fish!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top