Pasting Excel chart to Powerpoint SlideShow difficulties

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

Hi there,
I'm pasting a chart from Excel(2002) into my PPt (2002) presentation
with the following macro:

Sub FinaliseIt()
On Error GoTo Checkfiles_Err
Dim XLApp As Excel.Application

' Reference existing instance of Excel


Set XLApp = GetObject(, "Excel.Application")
XLApp.ActiveWorkbook.Activate

'Run XL macro
XLApp.Sheets("Sheet1").Select

XLApp.ActiveSheet.ChartObjects("Chart 5").Activate
XLApp.ActiveChart.ChartArea.Select

' Copy chart as a picture
XLApp.ActiveChart.CopyPicture Appearance:=xlScreen,
Size:=xlScreen, _
Format:=xlPicture

'Reference active PPT presentation
PowerPoint.Application.Visible = True
PowerPoint.Application.Activate


'PowerPoint.ActivePresentation.SlideShowWindow.View.GotoSlide 23
PowerPoint.ActiveWindow.View.GotoSlide Index:=23
PowerPoint.Application.Activate
PowerPoint.Application.Visible = msoCTrue

'Paste the chart into the presentation
PowerPoint.Application.ActiveWindow.View.Paste

..........'do more stuff here

End sub

This runs well but, and here's my problem, the slideshow view changes
to normal view.
Can I prevent this change from happening somehow?

Apologies if this is obvious
thank you in anticipation

Simon
 
Simon,
You can working with the PowerPoint design window and activating it -
PowerPoint.Application.Activate- hence the window will get activated. I am
assuming you are attempting to paste it while the slideshow is running, in
which can you should paste using the into the slide reference rather than
ActiveWindow.
 
Hi Shyam,
Thank you for your post. You are correct I am trying to paste into
the SlideShow whilst it is running.
Could you or one of our friends help me further please? I changed the
code from the original post to the following:

'Select and copy the chart from Excel
XLApp.ActiveSheet.ChartObjects("Chart 5").Activate
XLApp.ActiveChart.ChartArea.Select

' Copy chart as a picture
XLApp.ActiveChart.CopyPicture Appearance:=xlScreen,
Size:=xlScreen, _
Format:=xlPicture

'Reference active PPT presentation

PowerPoint.Application.Visible = True
PowerPoint.Application.Activate

' Paste the picture onto the PowerPoint slide.
ActivePresentation.Slides(23).Shapes.Paste
'Do other stuff.

Unfortunately this still takes me back to the active window and
doesn't remain in slideshow view. I am trying to run this PP show
from a web browser so it gives me an error message as there isn't an
active window when viewed this way.

As you can see I'm a novice at this vba stuff. Could you help me with
a code suggestion please?

Thank you once again
 
Back
Top