noboffinme
Registered User.
- Local time
- Today, 15:07
- 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 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