Link to home
Start Free TrialLog in
Avatar of John Carney
John CarneyFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Carney

ASKER

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

Thanks for such an easy-to-follow answer :- )
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.