2011-08-25 16 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

發生我剛剛在同一個釘子上跳動。 ;-) –

相關問題