Pasting Excel chart to Powerpoint SlideShow difficulties

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
 
S

Shyam Pillai

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.
 
S

simon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top