I am trying to use VBA coding - which I am pretty new to - to obtain a series of .doc documents from PDFs (which are not images), that is, I am trying to loop over various P
As others have stated, the problem seems to lie mostly with the path & file name. Here is the second version of the code you posted with some changes.
Unfortunately, a warning message pops up and setting DisplayAlerts to false will not suppress it. But if you click the "don't show this message again" checkbox the first time it pops up, then it will not continue to pop up for every file.
Sub convertToWord()
Dim MyObj As Object
Dim MySource As Object
Dim file As String
Dim path As String
path = "C:\Users\username\work_dir_example\"
file = Dir(path & "*.pdf")
Do While (file <> "")
Documents.Open FileName:=path & file
With ActiveDocument
.SaveAs2 FileName:=Replace(path & file, ".pdf", ".docx"), _
FileFormat:=wdFormatXMLDocument
.Close
End With
file = Dir
Loop
End Sub