我正在使用 C# 以编程方式创建 PowerPoint 2007 演示文稿,但是当我添加文本时,第二行缩进了。在 UI 中,我会通过转到“主页”->“段落”->“缩进”并将“文本前”设置为“0”并将特殊设置为“(无)”来进行设置。我怎样才能以编程方式完成同样的事情?
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();
那么...我该如何放弃悬挂缩进?
最佳答案
在 PPT 2007 及更高版本中,使用形状的 TextFrame2.Textrange.Paragraphs(x).ParagraphFormat 特性。 .LeftIndent 为您提供段落的整体缩进,.FirstLineIndent 为您提供第一行的缩进(它与 .LeftIndent 值相关)
关于c# - 如何使用 PowerPoint API 控制悬挂缩进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7191505/