PDA

View Full Version : Powerpoint Table Indent



magnel
07-18-2013, 08:45 PM
Hello Friends,

I am using PPT 2010 and I have a table whose indent looks something like the image below
http://internetprofitz.com/wp-content/uploads/2013/07/Indent-Levels.jpg

Please can someone help me with a code to set all the indent to the image below
http://internetprofitz.com/wp-content/uploads/2013/07/Actual.jpg

John Wilson
07-25-2013, 01:02 AM
Sub TableFix()
Dim otbl As Table
Dim iRow As Integer
Dim iCol As Integer
On Error GoTo err
Set otbl = ActiveWindow.Selection.ShapeRange(1).Table
For iRow = 1 To otbl.Rows.Count
For iCol = 1 To otbl.Columns.Count
With otbl.Cell(iRow, iCol).Shape.TextFrame2.TextRange.ParagraphFormat
.FirstLineIndent = 0
.LeftIndent = 0
End With
Next iCol
Next iRow
Exit Sub
err:
MsgBox "Error. Did you select a table?"
End Sub

magnel
07-25-2013, 04:49 AM
Works perfectly as always, many thanks to you John for the long awaited piece of code.

magnel
07-31-2013, 05:02 AM
Hi John, the above code works very well for selected table. But if we have to change the indent of all tables in the entire presentation, please can you let me know what should be the change in this piece of code.

John Wilson
07-31-2013, 08:19 AM
Something like this.

Sub allTables_Main()
Dim osld As Slide
Dim otbl As Table
Dim oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoTable Then
Set otbl = oshp.Table
Call setTable(otbl)
End If
If oshp.Type = msoPlaceholder Then
If oshp.PlaceholderFormat.ContainedType = msoTable Then
Set otbl = oshp.Table
Call setTable(otbl)
End If
End If
Next oshp
Next osld
End Sub

Sub setTable(otbl As Table)
Dim iRow As Integer
Dim iCol As Integer
For iRow = 1 To otbl.Rows.Count
For iCol = 1 To otbl.Columns.Count
With otbl.Cell(iRow, iCol).Shape.TextFrame2.TextRange.ParagraphFormat
.FirstLineIndent = 0
.LeftIndent = 0
End With
Next iCol

magnel
07-31-2013, 06:41 PM
Like always John, the code works perfectly. thank you so much :)