2011-08-25 17 views
2

我正在编程创建一个C#中的PowerPoint 2007演示文稿,但是当我添加文本时,第二行是缩进的。在UI中,我将通过进入Home-> Paragraph->缩进并将“Before Text”设置为“0”并将Special设置为“(none)”来设置它。我怎样才能以编程方式完成同样的事情?如何使用PowerPoint API控制悬挂缩进?

 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(); 

那么...我如何沟悬挂缩进?

回答

2

在PPT 2007及更高版本中,使用形状的TextFrame2.Textrange.Paragraphs(x).ParagraphFormat 属性。 .LeftIndent为您提供了该段的整体缩进.FirstLineIndent为您提供了第一行的缩进(并且它与.LeftIndent值相关)。

+0

您击中了头部!谢谢史蒂夫! –

+0

发生我刚刚在同一个钉子上跳动。 ;-) –

相关问题