代码:
Set argv = WScript.Arguments
if argv.Count < 1 then
WScript.Quit
end if
Set pptApp = CreateObject("PowerPoint.Application")
For Each arg In argv
filename = arg
if right(filename, 3) = "ppt" or right(filename, 3) = "pps" then
pdfname = left(filename, len(filename)-3) & "pdf"
elseif right(filename, 4) = "pptx" then
pdfname = left(filename, len(filename)-4) & "pdf"
else
msgbox(filename & " is not ppt/pptx!")
continue ' Skip to the next file
end if
Set MyPress = pptApp.Presentations.Open(filename)
ppSaveAsPDF = 32
MyPress.SaveAs pdfname, ppSaveAsPDF, false
MyPress.Close
Next
pptApp.Quit
使用方法:
新建txt,将上述代码粘进去,将文件重命名为.vbs文件
将单个或多个ppt或pptx文件拖动到该vbs文件上,即可调用Microsoft PowerPoint在源目录生成pdf
WPS没测试过,但是理论上应该不行
运行效果: