1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 利用vbs将word excel ppt转换成pdf

利用vbs将word excel ppt转换成pdf

时间:2019-07-31 06:05:08

相关推荐

利用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文件

主要是参考这位前辈的附上地址/dqmtqqq/article/details/54848432

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。