Friday, July 15, 2011

copy data from text boxes in powerpoint to excel in excel VBA

If you would like to import the text from the text boxes in powerpoint slides to excel sheet

Here is the code-

Sub import_textbox_text_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
Dim abc As Table
Set PPApp = New PowerPoint.Application

i = 1
PPApp.Visible = True

Set PPPres = PPApp.Presentations.Open("C:\Documents and Settings\achamanlalko\Desktop\powerpoint to excel\export text from text box to excel.pptx")

For Each oPS In PPPres.Slides

For Each Shp In oPS.Shapes
If Shp.TextFrame.HasText Then
' shape name
ThisWorkbook.Sheets(1).Cells(i, 1).Value = Shp.Name
' slide name
ThisWorkbook.Sheets(1).Cells(i, 2).Value = oPS.Name
' shape text
ThisWorkbook.Sheets(1).Cells(i, 3).Value = Shp.TextFrame.TextRange.Text
i = i + 1
End If

Set PPSlide = Nothing

Set PPPres = Nothing
Set PPApp = Nothing
MsgBox "done"

End Sub

Powerpoint Slide

Excel Macro File

No comments:

Post a Comment