0

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.

Kamlesh Kishor
  • 121
  • 1
  • 15
  • I haven't time to test this right now, but if the cell is empty, add "dummy" text to it, set a flag to indicate that the cel should be empty, run your code on it, then if the flag is set, delete the text again. – Steve Rindsberg Jun 18 '16 at 15:53
  • i was also thinking of doing the same but somehow it was not working for me. It worked now. Problem solved. Macro complete.Thanku :) – Kamlesh Kishor Jun 18 '16 at 18:53

1 Answers1

4

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
Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24