+ Reply to Thread
Results 1 to 2 of 2

Copy range in excel and paste in Powerpoint VBA

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    1

    Copy range in excel and paste in Powerpoint VBA

    Hello all,

    I am using the below code to copy a range of cells from excel (Range includes data and chart) "A1:N59" to a slide on Powerpoint. It works just fine, but the only problem is that it is pasting as a picture and I want it to do a Paste Special in PowerPoint and paste as a Microsoft Office Excel Workbook Object. Is this possible? The problem with the way it is pasting is that it pastes as a very large image and when I manually copy and paste it as an Excel Workbook Object, the formatting remains perfect. Any thoughts would be much apprectiated. Thanks!

    Please Login or Register  to view this content.
    ' Set a VBE reference to Microsoft PowerPoint Object Library
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide
    Range("A1:N59").Select
    If Not TypeName(Selection) = "Range" Then
    MsgBox "Please select a worksheet range and try again.", vbExclamation, _
    "No Range Selected"
    Else
    ' 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 picture
    Selection.CopyPicture Appearance:=xlScreen, _
    Format:=xlPicture
    ' Paste the range
    PPSlide.Shapes.Paste.Select
    ' Align the pasted range
    PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    ' Clean up
    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing
    End If
    End Sub
    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    05-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Copy range in excel and paste in Powerpoint VBA

    Hi
    This might be what you are looking for...


    http://www.ozgrid.com/forum/showthread.php?t=145082

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1