这里是批量将pdf转换成word的一个程序
Sub convertToWord()
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("E:\2018\xuweijie\pdf\" & "*.pdf") 'pdf path
On Error GoTo ErrorHandler
Do While (file <> "")
ChangeFileOpenDirectory "E:\2018\xuweijie\pdf\" 'pdf path
Documents.Open FileName:=file
ChangeFileOpenDirectory "E:\2018\xuweijie\docx\" 'docx path
ActiveDocument.SaveAs2 FileName:=Replace(file, ".pdf", ".docx"), FileFormat:=wdFormatXMLDocument
ActiveDocument.Close
file = Dir
Loop
ErrorHandler:
file = Dir
Resume Next
End Sub
现在问题是能够跑,一开始文件没错,因为有的pdf用word打不开,然后之后的文件就全部错了
Sub convertToWord()
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("E:\2018\xuweijie\pdf\" & "*.pdf") 'pdf path
On Error GoTo ErrorHandler
Do While (file <> "")
ChangeFileOpenDirectory "E:\2018\xuweijie\pdf\" 'pdf path
Documents.Open FileName:=file
ChangeFileOpenDirectory "E:\2018\xuweijie\docx\" 'docx path
ActiveDocument.SaveAs2 FileName:=Replace(file, ".pdf", ".docx"), FileFormat:=wdFormatXMLDocument
ActiveDocument.Close
file = Dir
Loop
ErrorHandler:
file = Dir
Resume Next
End Sub
现在问题是能够跑,一开始文件没错,因为有的pdf用word打不开,然后之后的文件就全部错了