我用的是精简的office 2007,将代码保存在TXT文件,之后将.txt改成.vbs就行。代码如下:
On Error Resume Next
Set ppt = CreateObject(“PowerPoint.application”)
Set fso = WScript.CreateObject(“Scripting.Filesystemobject”)
Set fds = fso.GetFolder(“E:\1-1”) '此处可以写自已文件所在的文件夹
Set ffs = fds.Files
For Each ff In ffs
If (LCase(Right(ff.Name,4))=".ppt" Or LCase(Right(ff.Name,4))=“pptx” ) And Left(ff.Name,1)<>"~" Then
Set pptfile = ppt.Presentations.Open(ff.Path,false,false,false)
pptfile.Saveas Left(ff.Path,InStrRev(ff.Path,"."))&“pdf”,32,false
If Err.Number Then
MsgBox Err.Description
End If
End If
Next
pptfiles.Close
ppt.Quit
Set pptfile = Nothing
Set ppt = Nothing
Set objFSO = CreateObject(“Scripting.FileSystemObject”) '此处是转换后删掉PPT文件的
objFSO.DeleteFile(“E:\1-1*.ppt”)
objFSO.DeleteFile(“E:\1-1*.pptx”)
MsgBox “PPT文件已全部轩换为PDF格式!并且已删除PPT文档!”
你可以试下,应该是没有问题的,我本人一直在用……
用VBS代码写PPT/PPTX批量转PDF,绝对可用,本人就在用着……ppt转pdf代码
最新推荐文章于 2023-10-27 21:38:59 发布