【发布时间】:2017-03-21 10:29:52
【问题描述】:
我正在从 Excel-VBA 文件创建 PPT,并希望将 ppt 的缩放设置为 100%。
如何在不激活 PowerPoint 窗口的情况下从 Excel 文件执行此操作?
或者我怎么能通过激活窗口来做到这一点?
以下excel中的示例代码在桌面上打开一个ppt文件并尝试设置此ppt的缩放但似乎不起作用:
Sub CreatePptAndSetZoom()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim strTemplate$
'Look for existing instance of PPT
On Error Resume Next
Set ppApp = GetObject(, "PowerPoint.Application")
On Error GoTo 0
'Create new instance of PPT if no instance exists
If ppApp Is Nothing Then Set ppApp = New PowerPoint.Application
'Define Path of Template and open new ppt
strTemplate = Environ("UserProfile") & "\Desktop\Test.pptx"
Set ppPres = ppApp.presentations.Open(strTemplate, False, True, True)
'Set Zoom
ppApp.ActiveWindow.View.Zoom = 100
End Sub
在 Excel 文件中设置来自 Excel 文件的缩放使用稍有不同的语句(不带 View):
Application.ActiveWindow.Zoom = 100
有没有人知道如何在没有ppt文件中的任何代码的情况下解决这个问题?
【问题讨论】:
标签: vba excel powerpoint