Creating Macros in PPT 2010

I'm new to Powerpoint and I want to learn how to format table elements but unfortunately I'm using PPT 2010 and I can't record macros. Here are a few starter questions:

How do I find the table name so I can reference it in the macro?
How do I reset the shading of a row or group of rows to, say, RGB ( 102,102,153)
How do I set the vertical alignment of the table to middle?

What is everything I would need to include in a macro that will accomplish these 3 objectives?

Thanks,
John
LVL 1
John CarneyReliability Business Tools Analyst IIAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JSRWilsonCommented:
You can name the table (or find the name) Home Tab > Select > selection Pane

Then use that name like this:

Sub tabler()
Dim otbl As Table
Dim R As Long
Dim C As Long
Set otbl = ActivePresentation.Slides(1).Shapes("tbl").Table
' all cells to vertical middle
For R = 1 To otbl.Rows.Count
For C = 1 To otbl.Columns.Count
otbl.Cell(R, C).Shape.TextFrame2.VerticalAnchor = msoAnchorMiddle
Next C
Next R
'rows 2 & 3 fill
For R = 2 To 3 'rows
For C = 1 To otbl.Columns.Count 'columns
otbl.Cell(R, C).Shape.Fill.ForeColor.RGB = RGB(102, 102, 153)
Next C
Next R
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John CarneyReliability Business Tools Analyst IIAuthor Commented:
What a great start, thank you JSR! I'll try not to wear you out but for the purposes of this question can you tell me how I could alternate the row colors so that in my 7 row table (counting the header), rows 2, 4 and 6 are one color, and 3, 5 and 7 are another? Also how do I set the color of the border lines to, say, RGB(191, 191, 191)?

Here's my slightly modified code as of now:
Sub tabler()
Dim otbl As Table
Dim R As Long
Dim C As Long
Set otbl = ActivePresentation.Slides(1).Shapes("Table 6").Table
' all cells to vertical middle
For R = 1 To otbl.Rows.Count
For C = 1 To otbl.Columns.Count
otbl.Cell(R, C).Shape.TextFrame2.VerticalAnchor = msoAnchorMiddle
Next C
Next R
'rows 2 & 3 fill
For R = 2 To otbl.Rows.Count 'rows
For C = 1 To otbl.Columns.Count 'columns
'otbl.Cell(R, C).Shape.Fill.ForeColor.RGB = RGB(102, 102, 153)
otbl.Cell(R, C).Shape.Fill.ForeColor.RGB = RGB(229, 229, 255)
Next C
Next R
For C = 1 To otbl.Columns.Count 'columns
otbl.Cell(1, C).Shape.Fill.ForeColor.RGB = RGB(102, 102, 153)
Next C
End Sub

Open in new window

John CarneyReliability Business Tools Analyst IIAuthor Commented:
Thanks for such an easy-to-follow answer :- )
JSRWilsonCommented:
Time for a new question really but have a look at:

Sub tabler()
Dim otbl As Table
Dim R As Long
Dim C As Long
Dim B As Long
Set otbl = ActivePresentation.Slides(1).Shapes("Table 6").Table
' all cells to vertical middle
For R = 1 To otbl.Rows.Count
For C = 1 To otbl.Columns.Count
otbl.Cell(R, C).Shape.TextFrame2.VerticalAnchor = msoAnchorMiddle
For B = 1 To 4 'borders left,right,top,bottom
otbl.Cell(R, C).Borders(B).Visible = msoTrue
otbl.Cell(R, C).Borders(B).ForeColor.RGB = RGB(191, 191, 191)
Next B
Next C
Next R
'rows fill
For R = 1 To otbl.Rows.Count 'rows
For C = 1 To otbl.Columns.Count 'columns
If R / 2 <> R \ 2 Then 'odd rows
otbl.Cell(R, C).Shape.Fill.ForeColor.RGB = RGB(102, 102, 153)
Else
otbl.Cell(R, C).Shape.Fill.ForeColor.RGB = RGB(229, 229, 255)
End If
Next C
Next R
End Sub

Open in new window


The border will not be very obvious with those colors.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft PowerPoint

From novice to tech pro — start learning today.