使用Excel VBA代码将PDF转换为Word Doc [英] Convert PDF to Word Doc using excel VBA code
问题描述
每个人.我需要一个VBA代码将excel数据转换为PDf转换为word doc,我写了一个宏,将excel打印为pdf,但现在我想将其打印为该pdf中的word,所以简短版本是Excel到PDF到Word.所有这些对我想保持excel数据的格式
everyone. Im need a VBA code to convert excel data to PDf to word doc, i wrote a macro that prints out excel as a pdf but now i would like to print it out as word from that pdf, so short version, Excel to PDF to Word. all this do to i wanna keep the format of the excel data
推荐答案
我使用相同的基本代码,但始终收到一条错误消息,内容为错误保存到源文件.它可以被使用."我有"Adobe Acrobat PRO DC".我使用参考"Adobe Acrobat 10.0类型库"
I use same basic code, but I always get a Error message saying "Error saving to source file. It can be in use." I have "Adobe Acrobat PRO DC". I use reference "Adobe Acrobat 10.0 Type Library"
Option Explicit
Sub convert_pdf_doc()
Dim aApp As Acrobat.AcroApp
Dim av_doc As Acrobat.AcroAVDoc
Dim pdf_doc As Acrobat.AcroPDDoc
Dim jso_obj As Object
Dim sfile As String 'source file
Dim dfile As String 'destination file
Dim ext As String 'my choise of file
ext = "doc"
sfile = "C:\Temp\Test.pdf"
dfile = Replace(sfile, ".pdf", "." & ext, 1)
Set aApp = CreateObject("AcroExch.App")
Set av_doc = CreateObject("AcroExch.AVDoc")
If av_doc.Open(sfile, vbNull) = True Then
Set pdf_doc = av_doc.GetPDDoc
Set jso_obj = pdf_doc.GetJSObject
jso_obj.SaveAs dfile, "com.adobe.acrobat." & ext
End If
av_doc.Close False
aApp.Exit
Set aApp = Nothing
Set av_doc = Nothing
End Sub
这篇关于使用Excel VBA代码将PDF转换为Word Doc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!