【发布时间】:2017-03-10 23:19:14
【问题描述】:
我正在尝试使用 VBScript 保存然后关闭所有 Microsoft 应用程序,例如 word、excel 和 powerpoint。
我已经得到消息和擅长的工作:
'Word
On Error Resume Next
Set wd = GetObject(, "Word.Application")
On Error Goto 0
If Not IsEmpty(wd) Then
For Each doc In wd.Documents
doc.Save
doc.Close
Next
wd.Quit
End If
还有:
'Excel
On Error Resume Next
Set xl = GetObject(, "Excel.Application")
If Err Then
If Err.Number = 429 Then
WScript.Quit 0
Else
CreateObject("WScript.Shell").LogEvent 1, Err.Description & _
" (0x" & Hex(Err.Number) & ")"
WScript.Quit 1
End If
End If
On Error Goto 0
xl.DisplayAlerts = False
For Each wb In xl.Workbooks
wb.Save
wb.Close False
Next
xl.Quit
Set xl = Nothing
遗憾的是,我还没有弄清楚如何用 powerpoint 做同样的事情。我在网上研究过,但没有找到答案。我发现的所有工作都没有使用 VBScript。
这是我正在尝试制作的脚本:
'PowerPoint
On Error Resume Next
Set objPPT = GetObject("PowerPoint.Application")
On Error Goto 0
If Not IsEmpty(objPPT) Then
For Each doc In objPPT.Presentation
objPresentation.Save
objPresentation.Close
objPPT.Quit
Next
objPPT.Quit
End If
当我运行这个脚本时,什么也没有发生。
谁能帮我修复我的脚本吗?
谢谢!
我将不胜感激所花费的时间和精力!
【问题讨论】:
标签: vbscript save powerpoint