• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel to PPT

Surekha

Member
Hi, I need to paste excel range as bitmap on power point slide. But while pasting if my range height is greater than slide height then range has to be split into two slides accordingly. For e.g. My range height is 600 and my slide height is 540 then data has to be paste as per the height i.e. 540 on first slide and 60 on second slide
 
My Code for reference:
Code:
Sub CreatePPT()

    Dim PPApp As PowerPoint.Application
    Dim PPSlide As PowerPoint.Slide
    Dim sht As Worksheet
    Dim RangePasteType As String
    Dim rng1, rng2 As Range
    Dim oPPTPres As PowerPoint.Presentation
 
    If PPApp Is Nothing Then Set PPApp = New PowerPoint.Application
    If PPApp.Presentations.Count = 0 Then PPApp.Presentations.Add
    PPApp.Visible = True
 
    myPPT = ThisWorkbook.path & "\Cash - Supervisory_26th Feb'15.pptx"
    Set oPPTPres = PPApp.Presentations.Open(fileName:=myPPT)
    Set PPSlide = PPApp.ActivePresentation.Slides(8)
 
    Set sht = ThisWorkbook.Sheets("Sheet2")
    i = 9
    Set rng1 = sht.Range("A2:H" & i)
    'Set rng2 = sht.Range("A30:H61")
 
    If rng1.Height > 100 Then
        Do Until rng1.Height <= 100
            Set rng1 = sht.Range("A2:H" & i - 1)
            i = i - 1
        Loop
     
        rng1.Copy
     
        With PPSlide.Shapes.PasteSpecial(ppPasteMetafilePicture)
            .Align msoAlignCenters, True
            .Align msoAlignMiddles, True
            '.Item(1).ScaleHeight 2, msoCTrue, msoScaleFromMiddle
        End With
         
    End If

'    With PPApp.Presentations.Add
'        .SaveAs ("C:\Test.ppt")
'        .Close
'    End With
 
    Set PPSlide = Nothing
    Set PPApp = Nothing
End Sub
 
Last edited by a moderator:
Here I decrease the size of my range but now question is how should I copy that remaining range to new slide?
 
Surekha

In addition to what narayan said. I have attached a xl which might help in this regard.
 

Attachments

  • export_excel_dashboards_to_ppt.xls
    500 KB · Views: 6
Hi All,
Upload file for reference. In this code by default slide is 8. If data exceeds the height it will create new slide and paste data in it accordingly. But I want to create it more dynamic for future use. Please help. Want to create function so will just pass the start slide No and excel range and it will work accordingly.
 

Attachments

  • Sample.xlsm
    38.2 KB · Views: 4
Back
Top