Batch convert pdf to docx with microsoft office
By John Campbell •
I do like the way how word converts pdf's to docx format. The layout is almost flawless (tables/footers/headers etc). I tried out a lot of tools but Microsoft Word does it very very good.
Is there a way to batch convert a lot of pdf's to docx format with word? Some way of doing it with a command line utility or other way?
1 Answer
You can refer to the vba code below:
Option Explicit
Sub other2docx()
On Error Resume Next
Dim sEveryFile As String,sSourcePath As String,sNewSavePath As String
Dim CurDoc As Object
sSourcePath = "E:\file location\"
sEveryFile = Dir(sSourcePath &"*.pdf")
Do While sEveryFile <> "" Set CurDoc = Documents.Open(sSourcePath & sEveryFile, , , , , , , , , , , msoFalse) CurDoc.Convert sNewSavePath = VBA.Strings.Replace(sSourcePath & sEveryFile, ".pdf", ".docx") CurDoc.SaveAs2 sNewSavePath, wdFormatDocumentDefault CurDoc.Close SaveChanges:=False sEveryFile = Dir
Loop
Set CurDoc = NothingIt is easy to report errors when converting pdf to docx, and sometimes it will make the word stuck, so you can only use the task manager to end the word. Pay attention to which PDF file is causing the stuck, and then move this PDF file to another folder, do not let Word convert this file again.
2