none
PasteSpecial ppPasteEnhancedMetafile not working in 2010 RRS feed

  • Question

  • I have developed a macro enabled Excel based application in MS-Office 2007 version. In this application, I am trying to copy a chart as an image from Excel and paste the same as an image on a PowerPoint slide. The code used to work in MS-Office 2007. But when the same application is run on MS-Office 2010, it is giving error on the line "With Slide(n).Shapes.PasteSpecial(ppPasteEnhancedMetafile) ..... End With". Checked on lot of forums. Did not get a solution for this.

    Has someone been able to resolve this issue? If yes, could you please share the solution?

    Thanks in advance,

    Shiv.

    Tuesday, July 19, 2016 1:35 PM

Answers

  • Hi ShivKumarBS,

    try to use the code below. its working for paste special.

    Sub addchart()
        Dim pptApp As PowerPoint.Application
        Dim pptPres As PowerPoint.Presentation
        Dim pptSlide As PowerPoint.Slide
        Dim objChart As Object
        Set pptApp = New PowerPoint.Application
        Set pptPres = pptApp.Presentations.Add(msoTrue)
        Set objChart = Worksheets("Sheet1").ChartObjects("Chart 1").Chart
        objChart.ChartArea.Copy
        Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
        pptSlide.Shapes.PasteSpecial (ppPasteEnhancedMetafile)
    End Sub
    

    you can see the output below.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 20, 2016 4:58 AM
    Moderator