PPT VBA 学习讲义

2023-04-02 15:53:10   文档大全网     [ 字体:小 中 大 ] [ 阅读: ]

【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《PPT VBA 学习讲义》,欢迎阅读!
讲义,学习,PPT,VBA
PPT学习讲义

ActivePresentation.Slides(2).Shapes.Placeholders(1).Delete ActivePresentation.Save ActivePresentation.NewWindow

创建ppt文档。增加一张slide With Presentations.Add

.Slides.Add Index:=1, Layout:=ppLayoutTitle .SaveAs "Sample" End With

打开ppt文档。

Presentations.Open FileName:="c:\My Documents\pres1.ppt", _

ReadOnly:=msoTrue

创建保存ppt

Sub AddAndSave(pptPres As Presentation) pptPres.Slides.Add 1, 1

pptPres.SaveAs pptPres.Application.Path & "\Added Slide" End Sub

Slide标题删除与恢复

ActivePresentation.Slides(2).Shapes.Placeholders(1).Delete Application.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 text"


End With

将主题或设计模式应用于当前ppt ActivePresentation.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 = True

ActivePresentation.Slides(1).Shapes.Placeholders(1) _ .TextFrame.TextRange.Font.Italic = True

ActivePresentation.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 If Next


本文来源:https://www.wddqxz.cn/bcb537bc960590c69ec3769f.html

相关推荐