PPT VBA 学习讲义.docx

上传人:PIYPING 文档编号:11388496 上传时间:2021-08-01 格式:DOCX 页数:3 大小:19.55KB
返回 下载 相关 举报
PPT VBA 学习讲义.docx_第1页
第1页 / 共3页
PPT VBA 学习讲义.docx_第2页
第2页 / 共3页
PPT VBA 学习讲义.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《PPT VBA 学习讲义.docx》由会员分享,可在线阅读,更多相关《PPT VBA 学习讲义.docx(3页珍藏版)》请在三一文库上搜索。

1、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 Documentspres1.ppt, _ReadOnly:=msoTr

2、ue创建保存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当前演示文稿中添加一张幻灯

3、片,为该幻灯片标题(幻灯片第一个占位符)和副标题添加文本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将主题或设计模式应用于当前pptActivePrese

4、ntation.ApplyTheme若要在幻灯片中添加形状并返回一个代表新建形状的 Shape 对象,请使用 Shapes 集合的下列方法之一:AddCallout 、AddComment 、AddConnector 、AddCurve 、AddLabel 、AddLine 、AddMediaObject 、AddOLEObject 、AddPicture 、AddPlaceholder 、AddPolyline 、AddShape 、AddTable 、AddTextbox 、AddTextEffect 、AddTitle 。使用 Shapes.Title 返回代表幻灯片标题的 Shape

5、对象。使用 Shapes.AddTitle 在无标题的幻灯片中添加标题并返回代表新建标题的 Shape 对象。使用Shapes.Placeholders(index) 返回一个代表占位符的 Shape 对象,其中 index 是占位符的索引号。如果没有改变过幻灯片中形状的排列顺序,则以下三个语句是等价的(假设第一张幻灯片有标题)。ActivePresentation.Slides(1).Shapes.Title _ .TextFrame.TextRange.Font.Italic = TrueActivePresentation.Slides(1).Shapes.Placeholders(1)

6、 _ .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.TextFra

7、me If .HasText Then MsgBox .TextRange.Text End With End IfNext使用 TextFrame 对象的 TextRange 属性返回任意指定形状的 TextRange 对象。使用 Text 属性返回 TextRange 对象中的文本字符串。以下示例向 myDocument 中添加一个矩形并设置其包含的文本Set myDocument = ActivePresentation.Slides(1)myDocument.Shapes.AddShape(msoShapeRectangle, 0, 0, 250, 140) _ .TextFrame.

8、TextRange.Text = Here is some test text使用 HasTextFrame 属性判断形状是否含有文本框,然后使用 HasText 属性判断该文本框是否包含文本。使用 Selection 对象的 TextRange 属性返回当前选定的文字。以下示例将选定内容复制到剪贴板。ActiveWindow.Selection.TextRange.Copy使用下列方法之一可返回 TextRange 对象中的部分文本:Characters、Lines、Paragraphs、Runs、Sentences 或 Words。使用 Find 和 Replace 方法可查找和替换文本范

9、围内的文本。使用下列方法之一可向 TextRange 对象中插入字符:InsertAfter、InsertBefore、InsertDateTime、InsertSlideNumber 或 InsertSymbol。本示例创建活动演示文稿中第一张幻灯片的一个副本,然后设置新幻灯片的背景阴影和标题文本。新幻灯片将作为演示文稿的第二张幻灯片。Set newSlide = ActivePresentation.Slides(1).DuplicateWith newSlide .Background.Fill.PresetGradient msoGradientVertical, _ 1, msoGradientGold .Shapes.Title.TextFrame.TextRange _ .Text = Second Quarter EarningsEnd With增加回车换行控制符Chr(13) & Chr(10)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1