文档详情

PPT VBA 学习讲义.docx

发布:2018-11-23约2.88千字共3页下载文档
文本预览下载声明
PPT学习讲义ActivePresentation.Slides(2).Shapes.Placeholders(1).DeleteActivePresentation.SaveActivePresentation.NewWindow创建ppt文档。增加一张slideWith Presentations.Add .Slides.Add Index:=1, Layout:=ppLayoutTitle .SaveAs SampleEnd With打开ppt文档。Presentations.Open FileName:=c:\My Documents\pres1.ppt, _ReadOnly:=msoTrue创建保存pptSub AddAndSave(pptPres As Presentation) pptPres.Slides.Add 1, 1 pptPres.SaveAs pptPres.Application.Path \Added SlideEnd SubSlide标题删除与恢复ActivePresentation.Slides(2).Shapes.Placeholders(1).DeleteApplication.ActivePresentation.Slides(2) _ .Shapes.AddPlaceholder ppPlaceholderTitle当前演示文稿中添加一张幻灯片,为该幻灯片标题(幻灯片第一个占位符)和副标题添加文本Set myDocument = ActivePresentation.Slides(1)With ActivePresentation.Slides _ .Add(1, ppLayoutTitle).Shapes.Placeholders .Item(1).TextFrame.TextRange.Text = This is the title text .Item(2).TextFrame.TextRange.Text = This is subtitle textEnd With将主题或设计模式应用于当前pptActivePresentation.ApplyTheme若要在幻灯片中添加形状并返回一个代表新建形状的 Shape 对象,请使用 Shapes 集合的下列方法之一:AddCallout、AddComment、AddConnector、AddCurve、AddLabel、AddLine、AddMediaObject、AddOLEObject、AddPicture、AddPlaceholder、AddPolyline、AddShape、AddTable、AddTextbox、AddTextEffect、AddTitle。使用 Shapes.Title 返回代表幻灯片标题的 Shape 对象。使用 Shapes.AddTitle 在无标题的幻灯片中添加标题并返回代表新建标题的 Shape 对象。使用Shapes.Placeholders(index) 返回一个代表占位符的 Shape 对象,其中 index 是占位符的索引号。如果没有改变过幻灯片中形状的排列顺序,则以下三个语句是等价的(假设第一张幻灯片有标题)。ActivePresentation.Slides(1).Shapes.Title _ .TextFrame.TextRange.Font.Italic = TrueActivePresentation.Slides(1).Shapes.Placeholders(1) _ .TextFrame.TextRange.Font.Italic = TrueActivePresentation.Slides(1).Shapes(1).TextFrame _.TextRange.Font.Italic = True使用HasTextFrame属性判断形状是否含有文本框,并使用HasText属性判断该文本框是否包含文本,如以下示例所示。Set myDocument = ActivePresentation.Slides(1)For Each s In myDocument.Shapes If s.HasTextFrame Then With s.TextFrame If .HasText Then MsgBox .TextRange.Text End With End IfNext使用TextFrame对象的TextRange属性返回任意指定形状的 TextRange 对象。使用Text属性返回 TextRange 对象中的文本字符串。以下示例向myDocum
显示全部
相似文档