Hi,
I wrote a
VB application to harvest data from Powerpoint and dump it
into Word - or was it Excel? I don't remember - suffice to say I lost
all of the code when both my main and back up hard drives were trashed
during shipping. There's a lesson to be learnt there.
Anyway, as always, your best bet is to open up Powerpoint, record some
macros and explore the object model from there.
To get you started, basically you can either use late or early binding
to access Powerpoint. The below code demonstrates the dumping of all of
the textboxes
Sub PPEarlyBinding()
'Make a reference in your XL project to
'MS Powerpoint Object Model
Dim
Dim s As Slide
Dim sh As Shape
For Each s In ActivePresentation.Slides
For Each sh In s.Shapes
on error resume next
If sh.Type = msoAutoShape _
Or sh.Type = msoPlaceholder Then
Debug.Print sh.TextFrame.TextRange.Text
End if
on error goto 0
Next sh
Next s
End Sub
Sub PPLateBinding()
'no reference required
Dim oPP As Object
Dim oS As Object
Dim oSh As Object
'We assume PP is already open and has an active presentation
Set oPP = GetObject(, "PowerPoint.Application")
For Each oS In oPP.ActivePresentation.Slides
For Each oSh In oS.Shapes
on error resume next
If oSh.Type = 14 _
Or oSh.Type = 1 Then
Debug.Print oSh.TextFrame.TextRange.Text
End If
on error goto 0
Next oSh
Next oS
Set oPP = Nothing
End Sub
Word of warning / explanation: what confused me initially was
Placeholders. Read up on these!! Basically a slide has a pre-assigned
number of Placeholders i.e. textboxes. (You can change this but to no
more than 3 I think.). So if you loop through looking for the textboxes,
the original ones from the template will be type msoPlaceholder but any
others added by the user will be type msoAutoShape. It all makes sense
in the end but it's a tad frustrating initially.
Other than this, you may like to try microsoft.public.powerpoint for
specific Powerpoint info.
HTH,
Gareth
DB wrote:
I have a powerpoint presentation with one slide. There are text ranges and
shapes that I want to gather data from and copy to Excel. I'm not familar
with the powerpoint object model. Has anyone done this type of programming
that can help?
DB