Excel charts to Powerpoint

noboffinme

Registered User.
Local time
Today, 15:16
Joined
Nov 28, 2007
Messages
288
HI

I want add Excel charts to Powerpoint & be able to name the file the charts are coming from & going to.

I'm having trouble with the below where the file names are declared.

What's the best way to overcome this??

------------

Sub ChartToPresentation()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

'Make sure a chart is selected
Sheets("Sheet1").Select
ActiveSheet.ChartObjects("Chart 9").Activate
ActiveChart.ChartArea.Copy

If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation

----------------------------------
'Set PPPres = PPApp("Pres1") '- I want to name the PPoint Pres

-------------------------------------
Set PPPres = PPApp.ActivePresentation '- & not use the one here

PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides _
(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

' Copy chart as a picture
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
Format:=xlPicture
' Paste chart
PPSlide.Shapes.Paste.Select

' Align pasted chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End If
End Sub
 
I'm having trouble with the below where the file names are declared.

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation

----------------------------------
'Set PPPres = PPApp("Pres1") '- I want to name the PPoint Pres

-------------------------------------
Set PPPres = PPApp.ActivePresentation '- & not use the one here

Just focusing on this part here I would suggest you try something like this. Please note unlike Outlook, Word and Excel, Powerpoint must be visible.

Code:
PPApp.Visible = True
Set ppPres = PPApp.Presentations.Open("full_path_to_presentation")
 
Thanks darbid

Looks like what I need, Cheers
 

Users who are viewing this thread

Back
Top Bottom