Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA to Extract data from PowerPoint 1

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
IN
Hi all
i have this challenge to create a macro to extract data from ppt
i need to extract the data from tables in a ppt and paste them in Excel
i can extract data and paste it in excel
but the tables are printing one below other
like this
excel1_v9gaou.jpg


but i want the tables to to printed like this
excel2_hgbg7u.jpg
ppttable_u9uo6t.jpg


how the tables are placed in ppt in same way the tables need to be printed in excel

i tried with this macro but didnt work
Option Explicit

Sub ExportToExcelSheet()

'Declare PPT variables
Dim pptPres As Presentation
Dim pptSlide As Slide
Dim pptShape As Shape
Dim pptPlaceholder As PlaceholderFormat
Dim pptTable As Table

'Declare Excel variables
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlRange As Excel.Range

'Access the active presentation
Set pptPres = Application.ActivePresentation

On Error Resume Next

Set xlApp = GetObject(, "EXCEL.Application")
If Err.Number = 429 Then
Err.Clear
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
End If

Set xlBook = xlApp.Workbooks("Extract.xlsx")
Set xlSheet = xlBook.Worksheets("Sheet1")

For Each pptSlide In pptPres.Slides
For Each pptShape In pptSlide.Shapes
If pptShape.Type = msoTable Then
Set pptTable = pptShape.Table
pptShape.Copy
Set xlRange = xlSheet.Range("A100").End(xlUp)
If xlRange.Address <> "$A$1" Then
Set xlRange = xlRange.Offset(3, 0)
End If
xlSheet.Paste Destination:=xlRange
End If
Next
Next

xlSheet.Columns.Range("A1").ColumnWidth = 5
xlSheet.Columns.Range("B1").ColumnWidth = 25
xlSheet.Rows.RowHeight = 20
End Sub

how do i create a macro for this
thank you
 
Replies continue below

Recommended for you

why are you posting this in CATIA forum?

regards,
LWolf
 
What's the point of the "challenge" if you ask others to help you?
And I believe that even in it you've failed since this is the wrong forum. Post reported.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top