打开PowerPoint并从Excel复制到特定的幻灯片

我想要打开一个现有的PowerPoint模板并select幻灯片3并从我的电子表格复制到PowerPoint幻灯片。

请有人告诉我如何做到这一点?

Sub Open_PowerPoint_Presentation() 'Opens a PowerPoint Document from Excel Dim objPPT As Object Dim PPSlide As Object Set objPPT = CreateObject("PowerPoint.Application") Set PPSlide = objPPT.Slides(5) objPPT.Visible = True 'Change the directory path and file name to the location 'of your document objPPT.Presentations.Open "\\MI-FILESERVE1\Shared Folders\Shared_Business_Dev\assets\Tender Time Allocation Deck.pptx" PPSlide.Select End Sub 

小心: 如果集合为空,则无法粘贴幻灯片的形状

IE:你需要一个至less有一个标题或一个形状(正方形,三angular形…)的幻灯片,才能够粘贴剪贴板中复制的内容。

这里有一些基础知识 ,你应该改正excel行来复制你想要的东西:

 Sub Open_PowerPoint_Presentation() Dim objPPT As Object, _ PPTPrez As PowerPoint.Presentation, _ pSlide As PowerPoint.Slide Set objPPT = CreateObject("PowerPoint.Application") objPPT.Visible = True Set PPTPrez = objPPT.Presentations.Open("\\MI-FILESERVE1\Shared Folders\Shared_Business_Dev\assets\Tender Time Allocation Deck.pptx") Set pSlide = PPTPrez.Slides(5) If pSlide.Shapes.Count <> 0 Then 'Table ActiveWorkbook.Sheets("Sheet1").Range("Named Range").Copy pSlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile 'OR ActiveWorkbook.Sheets("Sheet1").Range("Named Range").CopyPicture pSlide.Shapes.Paste 'Charts ActiveWorkbook.Sheets("Graph1").ActiveChart.ChartArea.Copy pSlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile 'OR ActiveWorkbook.Sheets("Graph1").ActiveChart.ChartArea.CopyPicture pSlide.Shapes.Paste Else MsgBox "There is no shape in this Slide (" & pSlide.SlideIndex & ")." & vbCrLf & "Please use a slide with at least one shape, not a blank slide", vbCritical + vbOKOnly End If End Sub