PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 4.00 average.

Copying and pasting from Excel to Powerpoint using VBA

 
 
Emma
Guest
Posts: n/a
 
      16th Jun 2009
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
 
Reply With Quote
 
 
 
 
xlDominik
Guest
Posts: n/a
 
      16th Jun 2009
Hi Emma,

have a look at Jon Peltier's website for help:
http://peltiertech.com/Excel/XL_PPT.html

Hope this helps!
Dominik.


"Emma" wrote:

> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying and pasting an Auto Shape from PowerPoint 2003 to Word 200 Richard Microsoft Word Document Management 1 3rd Jun 2010 12:21 AM
Copying from excel and pasting as a metafile in powerpoint JG Microsoft Powerpoint 8 10th Jul 2009 11:03 PM
Copying and pasting makes Powerpoint crash Carolyn Microsoft Powerpoint 5 30th Nov 2008 02:22 PM
Vista vs PowerPoint - copying and pasting Claire Windows Vista General Discussion 1 25th Jun 2008 06:00 PM
Copying & pasting text between PowerPoint files Howard Joe Microsoft Powerpoint 3 6th Jun 2006 03:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 PM.