The code should be simple enough, though it failed when trying to execute the SaveAs command. The error message said the file might be in use so it cannot be written.
The target directory has nothing but the PDF file itself, and it's not opened before the code was run. I have no idea what went wrong.
Sub PDFSaveAs()
Dim AcroApp As Object, AcroAVDoc As Object, AcroPDDoc As Object, jso As Object
Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open("C:\Users\User\Downloads\123.pdf", vbNull) = True Then
Set AcroPDDoc = AcroAVDoc.GetPDDoc
Set jso = AcroPDDoc.GetJSObject
jso.SaveAs "C:\Users\User\Downloads\123.docx", "com.adobe.acrobat.docx"
End If
AcroAVDoc.Close False
AcroApp.Exit
Set jso = Nothing
Set AcroPDDoc = Nothing
Set AcroAVDoc = Nothing
Set AcroApp = Nothing
End Sub
I've read through all of the Preferences in Acrobat and figured the solution myself.
Preferences > Security (Enhanced) > Uncheck Enable Protected Mode at startup
Done! No more "file might be in use" error.