H
Henk
With code I found here I constructed the following :
Public Sub ChartToPowerPoint()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim NewIndex As Integer
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select
PPPres.Slides(NewIndex).Select
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
ActiveSheet.ChartObjects("Graph01").Activate
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
PPSlide.Shapes.Paste.Select
PPApp.ActiveWindow.Selection.ShapeRange.Height = 303.5
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
Exit Sub
End Sub
What I want to do is export the chart to the active PowerPoint presentation
on a new slide at the end of the presentation.
If there are no slides in the presentation at start, the code works 1 time,
2 times, n times, if I do not select another slide in the presentation
manually between the first and the n-th time.
If there are one slide in the presentation at start, the code fails the
first time and runs okay time after time after ending the macro, uless I
select again another slide in my presentation manually.
I get a message for line : PPSlide.Shapes.Paste.Select
Run-time error '-2147188160 (80048240)':
Shape (unknown member) : Invalid request. To select a shape, its view must
be active.
I cannot find out why it is not active (the chart is copied to the last,
new, slide by the way) and I cannot find a way to make it active.
Hope you can help me out.
Henk
Public Sub ChartToPowerPoint()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim NewIndex As Integer
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select
PPPres.Slides(NewIndex).Select
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
ActiveSheet.ChartObjects("Graph01").Activate
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
PPSlide.Shapes.Paste.Select
PPApp.ActiveWindow.Selection.ShapeRange.Height = 303.5
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
Exit Sub
End Sub
What I want to do is export the chart to the active PowerPoint presentation
on a new slide at the end of the presentation.
If there are no slides in the presentation at start, the code works 1 time,
2 times, n times, if I do not select another slide in the presentation
manually between the first and the n-th time.
If there are one slide in the presentation at start, the code fails the
first time and runs okay time after time after ending the macro, uless I
select again another slide in my presentation manually.
I get a message for line : PPSlide.Shapes.Paste.Select
Run-time error '-2147188160 (80048240)':
Shape (unknown member) : Invalid request. To select a shape, its view must
be active.
I cannot find out why it is not active (the chart is copied to the last,
new, slide by the way) and I cannot find a way to make it active.
Hope you can help me out.
Henk