简体   繁体   中英

Copying a Range from Excel and Pasting it into Powerpoint NOT as a metafile but as a table which you can edit in PPP

All I want to do is copy a range from Excel and then paste this range into PowerPoint.

When my range is manually copied from Excel to the clipboard... If I right click on a blank slide when pasting into PowerPoint, it gives me the option to paste "using destination styles".

This means that I can edit the resulting table. This is the result I want.

So far I have only found solutions which involve pasting in as a metafile.

If you have a solution please can you show me the full code including the dimensions as VBA in PowerPoint really isn't my cup of tea.

Thanks in advance for restoring my sanity!

Private Sub CommandButton2_Click()

        Dim newPowerPoint As PowerPoint.Application
        Dim activeSlide As PowerPoint.Slide
        Dim cht As Excel.ChartObject


     'Look for existing instance
        On Error Resume Next
        Set newPowerPoint = GetObject(, "PowerPoint.Application")
        On Error GoTo 0



    'Show the PowerPoint
        newPowerPoint.Visible = True


            newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.count
            Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.count)


            ActiveSheet.Range("d51:d57").Copy
            activeSlide.Shapes.PasteSpecial ppPasteEnhancedMetafile
            newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 165
            newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 395

    AppActivate ("Microsoft PowerPoint")

    Set activeSlide = Nothing
    Set newPowerPoint = Nothing

End Sub

There appears to be no corresponding method in the PowerPoint object model. The only way to do this is to call the ribbon button itself:

ActiveSheet.Range("d51:d57").Copy
newPowerPoint.CommandBars.ExecuteMso("PasteExcelTableSourceFormatting")

BTW: To find the list of ribbon buttons, search for "Office 2010 Control IDs".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM