从 Excel 复制一个范围并将其粘贴到 Powerpoint 中,不是作为图元文件,而是作为 table,您可以在 PPP 中编辑

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

我只想从 Excel 复制一个范围,然后将此范围粘贴到 PowerPoint 中。

当我的范围从 Excel 手动复制到剪贴板时...如果我在粘贴到 PowerPoint 时右键单击空白幻灯片,它会给我粘贴 "using destination styles" 的选项。

这意味着我可以编辑结果 table。这就是我想要的结果。

到目前为止,我只找到了涉及作为图元文件粘贴的解决方案。

如果您有解决方案,请告诉我完整的代码,包括尺寸,因为 PowerPoint 中的 VBA 真的不是我的菜。

提前感谢您恢复我的理智!

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

PowerPoint 对象模型中似乎没有对应的方法。唯一的方法是调用功能区按钮本身:

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

顺便说一句:要查找功能区按钮列表,请搜索 "Office 2010 Control IDs"。