Reputation: 435
I would like to change text indentation in some PowerPoint object.
Paragraph -> Indentation -> before text
Paragraph -> Indentation -> Special -> Hanging (how to change it on FirstLine or None?) -> By
From that what I've found in previous versions it could be done with
paragraph.ParagraphFormat.FirstLineIndent = x;
paragraph.ParagraphFormat.LeftIndent = x;
but now there is no such properties available.
Upvotes: 3
Views: 377
Reputation: 6411
Okay, I figured it out. Here's the trick: the LeftIndent
and FirstLineIndent
properties only exist on the Microsoft.Office.Core.ParagraphFormat2
object. They do not exist on the regular Microsoft.Office.Interop.PowerPoint.ParagraphFormat
object.
You can still change the format for an entire TextRange though (it doesn't have to be done at the paragraph level as the comments above specify).
The trick is to access your shape's TextFrame2
property, instead of just TextFrame
, this will ensure that the classes you get back are TextRange2
, which will return a ParagraphFormat2
instead of a regular TextRange
and ParagraphFormat
.
The following code worked for me:
myShape.TextFrame2.TextRange.ParagraphFormat.LeftIndent = (.13f * 72f); // .13 inches
Upvotes: 1