怎样利用vbs和office批量转换pdf?这篇报道谁有详细教程?源码?win8怎么办?

2024-12-16 07:18:38
推荐回答(1个)
回答1:

我用的是精简的office 2007,代码如下:
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文档!"
你可以试下,应该是没有问题的,我本人一直在用……