Flora Edwards
asked on
VBA convert ppt to Excel
a picture is worth a thousand words.
i have the powerpoint with too many slides in it and i want to extract some text with bullet point and a text which is on the top. please see the result in excel how it should look like after vba is ran.
PP.pptx
Result.xlsx
i have the powerpoint with too many slides in it and i want to extract some text with bullet point and a text which is on the top. please see the result in excel how it should look like after vba is ran.
PP.pptx
Result.xlsx
Try something like this:
Sub TO_XL()
Dim osld As Slide
Dim L As Long
Dim XLapp As Object
Dim XLWB As Object
Dim rayData() As String
Dim char As Long
Dim iRow As Integer
Dim iCol As Integer
Dim myRange As Object
Set XLapp = CreateObject(Class:="Excel.Application")
XLapp.Visible = True
Set XLWB = XLapp.Workbooks.Add
XLWB.Sheets(1).Columns(1).ColumnWidth = 12
For L = 2 To 7
XLWB.Sheets(1).Columns(L).ColumnWidth = 25
Next L
Set myRange = XLWB.Sheets(1).Range("A1")
With XLWB.Sheets(1)
myRange.Offset(0, 0) = "STATE"
myRange.Offset(0, 1) = "(a)"
myRange.Offset(0, 2) = "(b)"
myRange.Offset(0, 3) = "(c)"
myRange.Offset(0, 4) = "(d)"
myRange.Offset(0, 5) = "(e)"
myRange.Offset(0, 6) = "(f)"
End With
iRow = 1
iCol = 1
For Each osld In ActivePresentation.Slides
ReDim rayData(1 To 1)
If osld.Shapes.HasTitle Then
rayData(1) = osld.Shapes.Title.TextFrame.TextRange
End If
With osld.Shapes(2).Table.Cell(1, 2).Shape.TextFrame2.TextRange
For L = 1 To .Paragraphs.Count
ReDim Preserve rayData(1 To UBound(rayData) + 1)
If .Paragraphs(L).ParagraphFormat.Bullet.Type = msoBulletNumbered Then
char = 96 + .Paragraphs(L).ParagraphFormat.Bullet.Number
rayData(UBound(rayData)) = "(" & Chr(char) & ")" & .Paragraphs(L).Text
Else
rayData(UBound(rayData)) = .Paragraphs(L).Text
End If
Next L
End With
myRange.Offset(iRow, 0) = rayData(1)
For L = 2 To UBound(rayData)
If Left(rayData(L), 3) = myRange.Offset(0, iCol).Text Then
myRange.Offset(iRow, iCol) = Mid(rayData(L), 4)
iCol = iCol + 1
End If
Next L
iRow = iRow + 1
iCol = 1
Next osld
End Sub
I would suggest that you NOT use excel but instead use access and to be brutally honest,
EE110116.accdb
EE110116.accdb
ASKER
thanks Wilson
i get error in line With osld.Shapes(2).Table.Cell( 1, 2).Shape.TextFrame2.TextRa nge
method 'table' of object 'shape' failed
i get error in line With osld.Shapes(2).Table.Cell(
method 'table' of object 'shape' failed
ASKER
hi David,
i tried your solution and when i downloaded and tried to open it with Access. i get the following error.
can't find language DLL msain.dll
then i tried opening it via Open file from application. it opened and i do not see any macro in the database file. how would i use this?
i tried your solution and when i downloaded and tried to open it with Access. i get the following error.
can't find language DLL msain.dll
then i tried opening it via Open file from application. it opened and i do not see any macro in the database file. how would i use this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks David
ASKER
first code which extract text from text boxes it works without error.
Open in new window
second code which is for tables inside the slides, it kinda does not work. it gives error.
Open in new window