我以编程方式在C#中创建PowerPoint 2007演示文稿,但是当我添加文本时,第二行是缩进的。在UI中,我将通过转到Home-> Paragraph->缩进并将“Before Text”设置为“0”并将Special设置为“(none)”来设置它。我怎样才能以编程方式完成同样的事情?
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();
那么......我怎么抛弃悬挂的缩进?
答案 0 :(得分:2)
在PPT 2007及更高版本中,使用形状的TextFrame2.Textrange.Paragraphs(x).ParagraphFormat 属性。 .LeftIndent为您提供段落的整体缩进,.FirstLineIndent为您提供第一行的缩进(并且它相对于.LeftIndent值)