Copying and pasting from Excel to Powerpoint using VBA

E

Emma

I'm using VBA in excel to automate copying a selection in excel and pasting
it into powerpoint as a picture. The problem i'm having is that the picture
is cutting off half of the selection I'm making. An extract of the code i'm
using is below, I know it is selecting the whole area, what and how do i need
to change in the copy and or paste part to paste the whole selection and then
resize it to fit the slide?

Sheets("PP offenders").Select
Range("b2:L11").Select

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

' Copy the range as a piicture
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlPicture

' Paste the range
PPSlide.Shapes.Paste.Select

' Position pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Left = 1
PPApp.ActiveWindow.Selection.ShapeRange.Top = 330
 

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