exceljockey
Member
Hi All
I have a problem at work where a lot of files I require in an excel format are already saved as PDFs, and the original excel files have been deleted (and are not retrievable).
If this was just for a couple of files, I would manually convert these files into text (so that I can then manipulate the data in Excel), but there are nearly a thousand files that I would need to do this for, so obviously I am in need of a macro.
Here is what I have so far:
Now the problem is, upon running the code, the last line:
gives me an error: Run-Time error '1001' UnsupportedValueError: Value is unsupported. ===> Parameter cConvID.
Now if I change the "NewFileName" to end in .pdf (instead of .txt) and then remove the "xlTextWindows" in the last line of code (essentially saving the pdf as pdf and thus not converting anything) then the code works fine, and the pdf is now saved as pdf under the new name of "file" rather than "file01".
Due to this, I think the problem lies in the .txt part of the code, and I dont think I am missing any Excel VBA references as the code works if I dont try to save as text.
Does anybody have any clue how to fix this?
Once its fixed, I can just put in a loop to go through all the files in the folder and convert them all to text, putting them into a different folder. After that, I can make another macro that goes into the text files and copies over the data I need.
Thanks,
EJ
I have a problem at work where a lot of files I require in an excel format are already saved as PDFs, and the original excel files have been deleted (and are not retrievable).
If this was just for a couple of files, I would manually convert these files into text (so that I can then manipulate the data in Excel), but there are nearly a thousand files that I would need to do this for, so obviously I am in need of a macro.
Here is what I have so far:
Code:
Sub convertpdf2()
Dim AcroXApp As Acrobat.AcroApp
Dim AcroXAVDoc As Acrobat.AcroAVDoc
Dim AcroXPDDoc As Acrobat.AcroPDDoc
Dim Filename As String
Dim jsObj As Object
Dim NewFileName As String
Filename = "C:\Documents and Settings\xxx\Desktop\file01.pdf"
NewFileName = "C:\Documents and Settings\xxx\Desktop\file.txt"
Set AcroXApp = CreateObject("AcroExch.App")
'AcroXApp.Show
Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
AcroXAVDoc.Open Filename, "Acrobat"
Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
Set jsObj = AcroXPDDoc.GetJSObject
jsObj.SaveAs NewFileName, xlTextWindows
AcroXAVDoc.Close False
AcroXApp.Hide
AcroXApp.Exit
End Sub
Code:
jsObj.SaveAs NewFileName, xlTextWindows
gives me an error: Run-Time error '1001' UnsupportedValueError: Value is unsupported. ===> Parameter cConvID.
Now if I change the "NewFileName" to end in .pdf (instead of .txt) and then remove the "xlTextWindows" in the last line of code (essentially saving the pdf as pdf and thus not converting anything) then the code works fine, and the pdf is now saved as pdf under the new name of "file" rather than "file01".
Due to this, I think the problem lies in the .txt part of the code, and I dont think I am missing any Excel VBA references as the code works if I dont try to save as text.
Does anybody have any clue how to fix this?
Once its fixed, I can just put in a loop to go through all the files in the folder and convert them all to text, putting them into a different folder. After that, I can make another macro that goes into the text files and copies over the data I need.
Thanks,
EJ