.DOC to .PDF in VBA

I have Acrobat 5.0 installed so I have access to Acrobat Distiller(acrodist.exe) and other Acrobat components.

This is what I use today:
Dim oConverter As ACRODISTXLib.PdfDistiller
Call LoadDoc(OriginalPath & FileItem.Name)     ' Opens word document
Call SetMark           'Sets a watermark on the .doc

'this will printout the .doc to a postscript file (.ps)
ActiveDocument.PrintOut False, False, , sPSfile, , , , , , , True
ActiveDocument.Close wdDoNotSaveChanges

oConverter.FileToPDF sPSfile, sPDFfile, ""      'converts the .ps file to .pdf
Kill sPSfile    ' delete the temporary .ps file

This method is very slow and there seems to be an extra step that is not needed(printout as .ps could conver the .doc file directly I suppose).

And I'm having trouble on some computers with the printout (ActiveDocument.PrintOut ) no matter what postscript printer I use some computers give me a message to check printer settings bla bla..).

Is there a better/faster/safer method to do this without involving third party apps or using hundreds of rows of code ?
Who is Participating?
SNilssonAuthor Commented:


This could work if (air code):
LastPrinter = Currentprinter

Currentprinter = "Acrobat Distiller"

'I need to set a path and filename here to avoid the save as dialog.

Currentprinter = LastPrinter

Any idéas ?

SNilssonAuthor Commented:
No one ?
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

cpgreenConnect With a Mentor Commented:
Have you tried.....

ActiveDocument.PrintOut Range:=wdPrintAllPages, OutputFileName:="c:\pdfdoc.pdf", PrintToFile:=True
SNilssonAuthor Commented:
Nope, but I dont see why the Range parmeter should make any difference.
But if your confidend that this will work I can try it.
unsure if it actually works.  I just used ActiveDocument.PrintOut Range:=wdPrintAllPages in my macro but according to the vba help file the above code should work.
SNilssonAuthor Commented:
Yes normaly it does, it works on my computer but on some other computers it does not I allready use the printout command in:
ActiveDocument.PrintOut False, False, , sPSfile, , , , , , , True
But on some computers it just wont work, I will look in to it further when I'm back at work on monday, right now i'm drinking beer and trying to forget about work :)
SNilssonAuthor Commented:
Points awarded for clean-up purpose, I will post again if I find a solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.