Kamlesh Kishor
Kamlesh Kishor

Reputation: 121

Set custom value for indentation and hanging in Powerpoint VBA

I am trying to set custom value for indentation and hanging for a cell in table in powerpoint using VBA. I am using the code shown below.

tb.Cell(1,1).Shape.TextFrame.Ruler.Levels(1).LeftMargin = 72 * 0.13
tb.Cell(1,1).Shape.TextFrame.Ruler.Levels(1).FirstMargin = 0

Here tb is the table. This is working fine if the cell is not empty. But if the cell is empty the values don't change. Is there a way to achieve this.

Upvotes: 0

Views: 2162

Answers (1)

Jamie Garroch - MVP
Jamie Garroch - MVP

Reputation: 2979

You need to set the paragraph formatting for text as opposed to cell margins. Use these:

With tb.Cell(1,1).Shape
  ' Before
  .TextFrame2.TextRange.ParagraphFormat.LeftIndent = 72 * 0.13
  ' Hanging
  .TextFrame2.TextRange.ParagraphFormat.FirstLineIndent = 0
End With

You can set it to be different for each paragraph as follows:

.TextFrame2.TextRange.Paragraphs(lStart, lLength).ParagraphFormat.LeftIndent

Upvotes: 4

Related Questions