Angelo
Angelo

Reputation: 33

Print to Adobe PDF fails from Word VBA

Been fighting with this for a while. Office 2007 and Adobe Pro 10.

Have VBA code to step through a directory tree and print .doc and .docx files to PDF Printer (set as default).

Code runs fine but when I try to open the file, Adobe says it can't because it's not a supported file type or is damaged. But, Adobe is the one that created it via the Adobe PDF printer.

If I manually print from within Word, it works just fine so I'm guessing it's something in the vba. All the parameters are fine - best I can tell, and I've sett the proper defaults/preferences. Note in the code below I even tried using the Application.Printout and got the same results.

Documents.Open FileName:="""" & FolderPath & "\" & sDocName & """", ReadOnly:=True ' Application.PrintOut FileName:="""" & FolderPath & "\" & sDocName & """", OutputFileName:=PDFDoc, _ PrintToFile:=True, Background:=True ActiveDocument.PrintOut OutputFileName:=PDFDoc, Background:=True Documents(sDocName).Close savechanges:=False PDFDoc is the fully qualified file name for the output. It's working fine as I can find the file where I expect it to be.

Upvotes: 2

Views: 1594

Answers (1)

Melipone
Melipone

Reputation: 640

As far as I know, PrintToFile:= True forces the format to be PS (postscript) rather than PDF. So you will need to convert the file from PS to PDF (which can be automated). Take a look at this link for an example.

Upvotes: 2

Related Questions