开发者

How to control hanging indents using the PowerPoint API?

开发者 https://www.devze.com 2023-03-31 05:39 出处:网络
I am programatica开发者_高级运维lly creating a PowerPoint 2007 presentation in C#, but when I add the text, the second line is indented. From the UI, I would set it by going to Home->Paragraph->Indent

I am programatica开发者_高级运维lly creating a PowerPoint 2007 presentation in C#, but when I add the text, the second line is indented. From the UI, I would set it by going to Home->Paragraph->Indentation and setting "Before Text" to "0" and Special to "(none)". How can I accomplish the same thing programatically?

        PowerPoint.Application app = new PowerPoint.Application();
        PowerPoint.Presentation p = app.Presentations.Add(Office.MsoTriState.msoTrue);
        app.Visible = Office.MsoTriState.msoTrue;

        PowerPoint.CustomLayout customLayout = p.SlideMaster.CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutText];

        PowerPoint.Slide slide = p.Slides.AddSlide(p.Slides.Count + 1, customLayout);
        PowerPoint.Shape textShape = slide.Shapes[2];

        textShape.TextFrame.TextRange.ParagraphFormat.Bullet.Type = PowerPoint.PpBulletType.ppBulletNone;
        PowerPoint.TextRange range1 = textShape.TextFrame.TextRange.InsertAfter(@"Just enough text so that wrapping occurs.");
        range1.Font.Size = 54;

        p.SaveAs(@"c:\temp\test1.pptx", PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue);
        p.Close();
        app.Quit();

So... how do I ditch the hanging indent?


In PPT 2007 and up, work with the shape's TextFrame2.Textrange.Paragraphs(x).ParagraphFormat properties. .LeftIndent gives you the overall indent for the paragraph, .FirstLineIndent gives you the indent for the first line (and it's relative to the .LeftIndent value)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号