Friday, July 15, 2011

Copy data from table in PowerPoint to Excel

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


No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...