如何使用 PowerPoint API 控制悬挂缩进?
我正在用 C# 以编程方式创建 PowerPoint 2007 演示文稿,但是当我添加文本时,第二行缩进。在用户界面中,我将通过转到“主页”->“段落”->“缩进”并将“文本前”设置为“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();
那么...我该如何放弃悬挂缩进呢?
I am programatically 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 PPT 2007 及更高版本中,使用形状的 TextFrame2.Textrange.Paragraphs(x).ParagraphFormat
特性。 .LeftIndent 为您提供段落的整体缩进,.FirstLineIndent 为您提供第一行的缩进(并且它相对于 .LeftIndent 值)
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)