Find and select table

G

Guest

I need to chang the last field in tables on different slides. It is always
the last table on the slides. After I manually select the table, I know how
to find the cell within the table I need to change, however, I don't know how
to find (using vba) and select the table so I can change the cell. I'm using
PPT 2003. So, using vba, how do I find the last table on each slide and then
select it? (If I have ten slides then I will end up changing ten tables).

Thank you.
 
S

Steve Rindsberg

I need to chang the last field in tables on different slides. It is always
the last table on the slides. After I manually select the table, I know how
to find the cell within the table I need to change, however, I don't know how
to find (using vba) and select the table so I can change the cell. I'm using
PPT 2003. So, using vba, how do I find the last table on each slide and then
select it? (If I have ten slides then I will end up changing ten tables).

Something like this. Air code. May require tweakage:

Function LastTable(oSld as Slide) as Shape
' Returns the last table on slide oSld

Dim oSh as Shape
Dim oTblShape as Shape

For each oSh in oSld.Shapes
If oSh.HasTable Then
' it's a table. set a reference to it
Set oTblShape = oSh
End If
Next ' Shape

' we've looked at each shape on the slide
' if there were any tables among them, then
' we have a reference to it in oTblShape
' Hand it back:
Set LastTable = oTblShape

End Function

Sub TestIt()
LastTable(ActivePresentation.Slides(1)).Select
End Sub
 
G

Guest

Steve,

Thank you, that worked perfectly!

Ron

Steve Rindsberg said:
Something like this. Air code. May require tweakage:

Function LastTable(oSld as Slide) as Shape
' Returns the last table on slide oSld

Dim oSh as Shape
Dim oTblShape as Shape

For each oSh in oSld.Shapes
If oSh.HasTable Then
' it's a table. set a reference to it
Set oTblShape = oSh
End If
Next ' Shape

' we've looked at each shape on the slide
' if there were any tables among them, then
' we have a reference to it in oTblShape
' Hand it back:
Set LastTable = oTblShape

End Function

Sub TestIt()
LastTable(ActivePresentation.Slides(1)).Select
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top