Home > front end >  Pasting Range from Excel to Ppt as image
Pasting Range from Excel to Ppt as image

Time:09-29

Hi have a code that Copy Range from Excel to Ppt as image. However when I give command for it to resize Height width top left it is not doing it bcoz of default setting of Lock Aspect ratio. Is there any way I can modify my code.

CodePudding user response:

Set .LockAspectRatio property of the shape to msoFalse

Option Explicit

Sub ppt()

    Dim PPTApp As PowerPoint.Application
    Dim PPTPres As PowerPoint.Presentation
    Dim PPTSlide As PowerPoint.Slide
    
    Set PPTApp = New PowerPoint.Application
    PPTApp.Visible = True
    Set PPTPres = PPTApp.Presentations.Add
    Set PPTSlide = PPTPres.Slides.Add(1, ppLayoutBlank)

    Range("A1:C10").Copy
    With PPTSlide.Shapes.PasteSpecial(ppPasteMetafilePicture)
        .LockAspectRatio = msoFalse
        .Left = 20
        .Top = 20
        .Width = 400
        .Height = 300
    End With
    
End Sub
  • Related