Microsoft.Office.Interop.PowerPoint.Presentation MyPres = null;//PPT應用的實例 Microsoft.Office.Interop.PowerPoint.Slide MySlide = null;//PPT中的幻燈片 MyPres = Globals.ThisAddIn.Application.ActivePresentation; // 當前ppt應用實例 MySlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide; //獲取當前選中的幻燈片 PowerPoint.Shape bg; //聲明一個shape bg = slide.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, MyPres.PageSetup.SlideWidth, 70); //添加一個shape,形狀為矩形(msoShapeRectangle) bg.Fill.ForeColor.RGB = ColorTranslator.ToOle(Color.LightGray); //設置它的背景填充色為灰色 bg.Line.Visible = Office.MsoTriState.msoFalse; //去掉邊框 bg.TextFrame.TextRange.Text=“hello” //設置它的插入文本內容 bg.TextFrame.HorizontalAnchor = Office.MsoHorizontalAnchor.msoAnchorCenter; //文本格式居中 bg .TextFrame.TextRange.Font.Size = 20; //文本字號 bg .Visible = Office.MsoTriState.msoFalse //設置自選圖形為不可見狀態 PowerPoint.Shape pic; string picParh = "http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"; pic = MySlide.Shapes.AddPicture(picParh, Office.MsoTriState.msoTrue, Office.MsoTriState.msoTrue, 50, 50, 100, 100); //下載一個網絡圖片,插入至當前幻燈片,並設置相關參數