+ Reply to Thread
Results 1 to 3 of 3

Copy Range and Paste as JPG (to PPT)

  1. #1
    Registered User
    Join Date
    01-13-2017
    Location
    Sweden
    MS-Off Ver
    2013
    Posts
    31

    Copy Range and Paste as JPG (to PPT)

    Hello I would like to export a range in Excel to a PowerPoint presentation. Everything is working great but the file size of the PPT is quite large. I would like to reduce it by changing the PasteDataType from Default to JPG, but I always get an error.

    Private Sub RangeToPowerPoint(rng As Range, slide As Integer, size As Double, _
    left As Integer, top As Integer, title As String)


    Calculate
    Dim pptSlide As PowerPoint.slide
    Dim shapeRng As PowerPoint.ShapeRange

    If slide = -1 Then
    'Count the slides and add a new one after the last slide.
    pptSlideCount = pptPres.Slides.Count
    Set pptSlide = pptPres.Slides.Add(pptSlideCount + 1, ppLayoutBlank)
    Else
    Set pptSlide = pptPres.Slides(slide)
    End If

    'Copy the range and paste as image
    rng.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
    Set shapeRng = pptSlide.Shapes.PasteSpecial(DataType:=0)

    shapeRng.Line.Visible = msoFalse
    shapeRng.left = left
    shapeRng.top = top

    shapeRng.ScaleHeight size, 2
    shapeRng.ScaleHeight size, msoCTrue
    shapeRng.ScaleWidth size, msoCTrue
    shapeRng.ZOrder msoSendToBack
    shapeRng.PictureFormat.CropLeft = 1
    shapeRng.PictureFormat.CropTop = 1

    End Sub
    Do you know how I could change the code to work with JPG?

    No other numbers than 0 are working (https://msdn.microsoft.com/en-us/vba...ion-powerpoint)

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    2013 / 2016 / 365
    Posts
    7,151

    Re: Copy Range and Paste as JPG (to PPT)

    See if this utility answers the question. It does not insert a JPEG but it copies and resizes a metafile object.

    https://www.excelforum.com/tips-and-...rom-excel.html
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    01-13-2017
    Location
    Sweden
    MS-Off Ver
    2013
    Posts
    31

    Re: Copy Range and Paste as JPG (to PPT)

    Thank you very much dflak. Working very good!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Loop through files in folder, copy range, Paste range to original workbook
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-09-2016, 05:33 PM
  2. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  3. copy paste macros
    By rrk2008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2014, 06:42 AM
  4. [SOLVED] Inputboxes to select range to copy and range to paste from different workbooks
    By graphicgoose in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-29-2014, 05:51 PM
  5. Replies: 4
    Last Post: 03-17-2013, 05:58 AM
  6. Copy/Paste range of data excluding certain rows and copy to another workbook
    By HoerbigAdm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-12-2012, 02:51 PM
  7. Change range of cells within VBA macro and copy and paste to fixed cell range
    By Mannyny in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-20-2012, 11:51 AM

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