使用Excel-VBA控制PowerPoint(最小化等)

时间:2014-08-02 13:29:08

标签: excel excel-vba powerpoint-vba vba

我刚修改了我的代码,使其与所有版本的办公室兼容(因此独立于PowerPoint 15.0库)。虽然代码有效,但我遇到了我需要解决的小问题。代码和错误如下。真的很感激帮助。谢谢!

新代码

Dim pptApp As Object
Set pptApp = CreateObject("Powerpoint.Application")
pptApp.Visible = True
pptApp.WindowState = ppWindowMinimized

错误 - Compile Error. Variable not defined. 错误 - “ppWindowMinimized”

“ppWindowMinimized”工作的旧代码

Dim pptApp As PowerPoint.Application
Set pptApp = New PowerPoint.Application
pptApp.Visible = True
pptApp.WindowState = ppWindowMinimized

对于新代码我也面临同样的错误:

pptApp.ActiveWindow.viewtype = ppViewNormal
myPPT.SaveAs target_dir, ppSaveAsDefault

1 个答案:

答案 0 :(得分:2)

由于您使用的是后期约束(http://msofficefun.wordpress.com/2011/02/26/early-binding-vs-late-binding-in-office-vba/),因此需要将'ppWindowMinimized'替换为'2'。对于正常窗口状态,请使用'1'并最大化窗口使用'3'