Tags: align, barb, horizontally, microsoft, msdn, powerpoint, programmatically, software, tables, text, vertically
Vertically and Horizontally Align text in tables
On Microsoft » Microsoft Powerpoint
4,960 words with 3 Comments; publish: Tue, 27 May 2008 02:09:00 GMT; (30062.50, « »)
How do I programmatically align text in tables so that it's centered
vertically and horizontally.
Thanks,
Barb Reinhardt
http://powerpoint.itags.org/q_powerpoint_49030.html
All Comments
Leave a comment...
- 3 Comments

- Hi Barb
Did you solve the gradient fill macro? (We can help if you didn't Email me)
This code will set all tables in the pres to middle centred text
Sub tablealign()
On Error GoTo errhandler
Dim Icol As Integer, Irow As Integer, oshp As Shape, osld As Slide
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoTable Then
With oshp.table
For Irow = 1 To .Rows.Count
For IColumn = 1 To .Columns.Count
With .Cell(Irow, IColumn).Shape.TextFrame
.HorizontalAnchor = msoAnchorCenter
.VerticalAnchor = msoAnchorMiddle
End With
Next IColumn
Next Irow
End With
End If
Next
Next
Exit Sub
errhandler:
MsgBox "sorry there's an error!", vbCritical, "www.PPTAlchemy.co.uk"
End Sub
--
---
Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
"Barb Reinhardt" wrote:
> How do I programmatically align text in tables so that it's centered
> vertically and horizontally.
> Thanks,
> Barb Reinhardt
#1; Tue, 27 May 2008 02:10:00 GMT

- PS Those IColumns should be Icol though it will still work as is!
--
---
Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
"John Wilson" wrote:
> Hi Barb
> Did you solve the gradient fill macro? (We can help if you didn't Email me)
> This code will set all tables in the pres to middle centred text
> Sub tablealign()
> On Error GoTo errhandler
> Dim Icol As Integer, Irow As Integer, oshp As Shape, osld As Slide
> For Each osld In ActivePresentation.Slides
> For Each oshp In osld.Shapes
> If oshp.Type = msoTable Then
> With oshp.table
> For Irow = 1 To .Rows.Count
> For IColumn = 1 To .Columns.Count
> With .Cell(Irow, IColumn).Shape.TextFrame
> .HorizontalAnchor = msoAnchorCenter
> .VerticalAnchor = msoAnchorMiddle
> End With
> Next IColumn
> Next Irow
> End With
> End If
> Next
> Next
> Exit Sub
> errhandler:
> MsgBox "sorry there's an error!", vbCritical, "www.PPTAlchemy.co.uk"
> End Sub
> --
> ---
> Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
> http://www.technologytrish.co.uk/ppttipshome.html
> email john AT technologytrish.co.uk
>
> "Barb Reinhardt" wrote:
> > How do I programmatically align text in tables so that it's centered
> > vertically and horizontally.
> >
> > Thanks,
> > Barb Reinhardt
#2; Tue, 27 May 2008 02:12:00 GMT

- Thanks. I got the gradients working. I just couldn't figure out the anchor
issue.
Thanks again.
"John Wilson" wrote:
> Hi Barb
> Did you solve the gradient fill macro? (We can help if you didn't Email me)
> This code will set all tables in the pres to middle centred text
> Sub tablealign()
> On Error GoTo errhandler
> Dim Icol As Integer, Irow As Integer, oshp As Shape, osld As Slide
> For Each osld In ActivePresentation.Slides
> For Each oshp In osld.Shapes
> If oshp.Type = msoTable Then
> With oshp.table
> For Irow = 1 To .Rows.Count
> For IColumn = 1 To .Columns.Count
> With .Cell(Irow, IColumn).Shape.TextFrame
> .HorizontalAnchor = msoAnchorCenter
> .VerticalAnchor = msoAnchorMiddle
> End With
> Next IColumn
> Next Irow
> End With
> End If
> Next
> Next
> Exit Sub
> errhandler:
> MsgBox "sorry there's an error!", vbCritical, "www.PPTAlchemy.co.uk"
> End Sub
> --
> ---
> Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
> http://www.technologytrish.co.uk/ppttipshome.html
> email john AT technologytrish.co.uk
>
> "Barb Reinhardt" wrote:
> > How do I programmatically align text in tables so that it's centered
> > vertically and horizontally.
> >
> > Thanks,
> > Barb Reinhardt
#3; Tue, 27 May 2008 02:13:00 GMT