c# - 如何使用 PowerPoint API 控制悬挂缩进?

标签 c# api ms-office powerpoint

我正在使用 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/

相关文章:

c# - Linux VPS 上的单声道垃圾收集

c# - 如何更改文本动态添加的按钮 C#

javascript - axios 在返回数据之前返回空数组

c# - MS Word 中的语法高亮显示

vba - Office365 Excel 访问工具 -> RegExp 库的引用菜单

c# - 我的 XPath 有什么问题?

c# - 不可为空的字符串类型,如何与 Asp.Net Core 选项一起使用

php - 如何使用 Telegram API 实现授权?

Python 3 获取和解析 JSON API

python - 为 MS-Office 用户报告图表和数据