13. Application 对象Sub T1()
'使用内置的Application对象
Dim ppt1 As PowerPoint.Application
Set ppt1 = PowerPoint.Application
MsgBox ppt1.ActivePresentation.Name
'创建并使用Application对象
Dim ppy2 As PowerPoint.Application
Set ppt2 = New PowerPoint.Application
MsgBox ppt1.ActivePresentation.Name
End Sub
14. Presentation 对象Sub T2()
'创建默认的新演示文稿
Dim pres As PowerPoint.Presentation
Set pres = Presentations.Add(WithWindow:=msoFalse)
'首次保存演示文稿
pres.SaveAs ("新的演示文稿.ppt")
'打开演示文稿
Set pres = Presentations.Open(FileName:="新的演示文稿.ppt")
End Sub
15. Slide 对象Sub T3()
'创建默认的新演示文稿
Dim pres As PowerPoint.Presentation
Set pres = Presentations.Add(WithWindow:=msoTrue)
'定义版式
Dim layout1, layout2 As CustomLayout
Set layout1 = pres.SlideMaster.CustomLayouts(1)
Set layout2 = pres.SlideMaster.CustomLayouts(2)
'添加幻灯片到演示文稿
pres.Slides.AddSlide Index:=1, pCustomLayout:=layout1
pres.Slides.AddSlide Index:=1, pCustomLayout:=layout2
End Sub
16. PowerPoint坐标系统幻灯片
模式放映模式
17. PowerPoint坐标系统幻灯片
模式放映模式
18. PowerPoint坐标系统
19. Shape 对象 '创建默认的新演示文稿
Dim pres As PowerPoint.Presentation
Set pres = Presentations.Add(WithWindow:=msoTrue)
'定义版式
Dim layout1, layout2 As CustomLayout
Set layout1 = pres.SlideMaster.CustomLayouts(1)
'添加幻灯片到演示文稿
Dim sli As Slide
Set sli = pres.Slides.AddSlide(Index:=1, pCustomLayout:=layout1)
sli.Layout = ppLayoutBlank
'绘制矩形
sli.Shapes.AddLine BeginX:=0 + 1, BeginY:=0 + 1, EndX:=720 - 1, EndY:=0 + 1
sli.Shapes.AddLine BeginX:=0 + 1, BeginY:=540 - 1, EndX:=720 - 1, EndY:=540 - 1
sli.Shapes.AddLine BeginX:=0 + 1, BeginY:=0 + 1, EndX:=0 + 1, EndY:=540 - 1
sli.Shapes.AddLine BeginX:=720 - 1, BeginY:=0 + 1, EndX:=720 - 1, EndY:=540 - 1
21. 窗口模式比较窗口模式使用场景窗口对象窗口集合当前窗口版本文档窗口文档窗口是容纳演示文稿的窗口。DocumentWindowWindowsActiveWindow支持所有版本放映窗口幻灯片放映窗口是容纳打开的幻灯片的窗口。SlideShowWindowSlideShowWindows无支持所有版本保护窗口来自 Internet 和其他可能不安全位置的文件会在“受保护的视图”窗口中打开。ProtectedViewWindowProtectedViewWindowsActiveProtectedViewWindow仅支持2010
22. 三种窗口模式 '窗口数量
MsgBox "文档窗口数量:" & Windows.Count
MsgBox "放映窗口数量:" & SlideShowWindows.Count
If Application.Version >= "14.0" Then
MsgBox "保护窗口数量:" & ProtectedViewWindows.Count
End If
'当前文档视图窗口
If Windows.Count > 0 Then
If (Windows(1).Active) Then
MsgBox "当前文档窗口:" & ActiveWindow.Caption
End If
End If
'当前放映视图窗口
If SlideShowWindows.Count > 0 Then
If (SlideShowWindows(1).Active) Then
MsgBox "当前放映窗口:" & ActivePresentation.Name
End If
End If
'当前保护视图窗口
If Application.Version >= "14.0" Then
If ProtectedViewWindows.Count > 0 Then
If (ProtectedViewWindows(1).Active) Then
MsgBox "当前保护窗口:" & ActiveProtectedViewWindow.Caption
End If
End If
End If