利用vbs将word、excel、ppt转换成pdf

代码如下:

Excel:

path = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path

Set objArgs = WScript. Arguments  
Set oExcel = CreateObject("Excel.Application") 
Set oWb = oExcel.Workbooks.Open(path & "\" & "tmp.xlsx") 
oWb.ExportAsFixedFormat xlTypePDF, path & "\" & "tmp.pdf", 1,1,1,1
oExcel.Visible = False
oExcel.quit 
Set oWb = Nothing 

Word:

path = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path

Set word = CreateObject("Word.application")

Set docx = word.Documents.Open(path & "\" & "tmp.doc")

docx.SaveAs path & "\"  & "tmp.pdf",17

docx.close(doNotSaveChanges)

word.Quit
set docx = nothing

Set word = nothing
 

PPT:

path = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path

Set ppt = CreateObject("PowerPoint.application")

Set pptfile = ppt.Presentations.Open(path & "\" & "tmp.ppt",false,false,false)

pptfile.Saveas path & "\" & "tmp.pdf",32,false
ppt.Quit
Set pptfile= nothing
 

 

path = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path表示获得当前文件所在的路劲

tmp.ppt为原始文件

tmp.pdf为转换过的pdf文件

主要是参考这位前辈的附上地址https://blog.csdn.net/dqmtqqq/article/details/54848432

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值