If you want to copy the data from all tables in PowerPoint slide and paste them on
Excel Worksheet . Try this macro -
Sub copy_ppt_excel()
' refrence select Microsoft powerpoint
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim oPS As PowerPoint.Slide
Dim Shp As Object
Set PPApp = New PowerPoint.Application
i = 1
PPApp.Visible = True
' open the slide
Set PPPres = PPApp.Presentations.Open("C:\Users\admin\Desktop\New Blog Look\Files Uploaded\sample.pptx")
' loop through all shapes
For Each oPS In PPPres.Slides
For Each Shp In oPS.Shapes
If Shp.HasTable Then ' check if shape is table
Shp.Copy ' copy shape
' paste them on excel sheet
ThisWorkbook.Sheets(1).Range("a65356").End(xlUp).Offset(5, 0).Select
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False
End If
Next
Next
' close the slides
PPPres.Close
PPApp.Quit
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
ThisWorkbook.Activate
ThisWorkbook.Sheets(1).Select
End Sub
Download Working File
Sub copy_ppt_excel()
' refrence select Microsoft powerpoint
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim oPS As PowerPoint.Slide
Dim Shp As Object
Set PPApp = New PowerPoint.Application
i = 1
PPApp.Visible = True
' open the slide
Set PPPres = PPApp.Presentations.Open("C:\Users\admin\Desktop\New Blog Look\Files Uploaded\sample.pptx")
' loop through all shapes
For Each oPS In PPPres.Slides
For Each Shp In oPS.Shapes
If Shp.HasTable Then ' check if shape is table
Shp.Copy ' copy shape
' paste them on excel sheet
ThisWorkbook.Sheets(1).Range("a65356").End(xlUp).Offset(5, 0).Select
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False
End If
Next
Next
' close the slides
PPPres.Close
PPApp.Quit
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
ThisWorkbook.Activate
ThisWorkbook.Sheets(1).Select
End Sub
Download Working File
No comments:
Post a Comment