同事问有没有批量把word和excel 转PDF的工具,要在原目录下生成pdf,网上应该有很多这类工具。自己想做个小工具,先用python,使用win32com,结果有的文档没有转换,问题一堆,最后还是使用最简单的VBS来实现,缺点没有界面不知道执行进度。
转换时,将这个脚本放在包含word/excel的根目录下,双击运行就可以了。
wsToPdf.vbs
dim ObjFSO,ObjWS,currentDir
dim fileCount,word_count,excel_count,delCount,logfile
filecCount = 0
word_count = 0
excel_count = 0
delCount = 0
Set ObjWS = WScript.CreateObject("wscript.shell")
currentDir = ObjWS.CurrentDirectory
logfile = currentDir & "\log.txt"
data = "是否开始对根目录下包含的所有文档进行文档转化?" & vbCrLf & vbCrLf _
& "文档根目录为:" & vbCrLf & vbCrLf _
& currentDir & vbCrLf & vbCrLf _
& "转化日志再根目录下:log.txt"
res = Msgbox(data,4+32+256,"Word/Excel 转换 PDF")
if res = 7 then
Set ObjWS = nothing
WScript.quit
end if
Set ObjFSO = CreateObject("
|