Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert MS Word files into PDF via VBA?

Status
Not open for further replies.

sudakov

Programmer
Jun 17, 2007
53
US
Hello,
I have multiple (hundreds) MS Word files in a folder.
I would like to write VBA code to convert them into respective PDF files.

Does anybody know if this is possible?
Has anyone done it before?

Thanks.
Sudakov.
 
Hi mintjulep,
do you have any suggestion how to do it?

Thank you.
Sudakov.
 
Hi sudakov,

Yes, this can certainly be done. A couple of key questions:
1) What version of Word are you using?
2) Do you have anything against downloading a free piece of software to use?

Reasons I ask...
1) If you are using Word 2007 or 2010, you can automate the process using default Microsoft libraries without resorting to third party software.
2) Regardless of the version, you can download PDFCreator (from Sourceforge) which has an exposed PDF creation API.

I have an example of using Word to print all open documents to a PDF using PDFCreator on my site ( I can also work through retooling this to your purposes as well.

Ken Puls, CMA - Microsoft MVP (Excel)
-||-
 
If you have Acrobat you can do it directly from Windows explorer. No need to write any code at all.

I suspect that other PDF creators have the same capability.
 
Hi Ken,
it is a valuable code.
Thank you.

Answering your questions:
1) I am using Word 2003.
2) As of now, my work environment doesn't allow me to download.

However, I have Adobe Acrobat 9 Standart edition installed.
Can Adobe Acrobat API be used?

Thanks.
Sudakov.
 
Hi Mintjulep,
You are correct - no need to write any code at all.
You can use Windows explorer, however you have to confirm a PDF-file name everytime.
In my case, I have hundreds of files, so I have to spend the whole day just clicking to confirm each file conversion.

Thanks.
Sudakov.
 
If you had started on the 19th when you first asked the question then you would be finished with your task.

Now you have not finished, in fact not even started, and you still have to spend a considerable amount of time developing and debugging code.

Yes, you can access the Acrobat API via VBA, but I think you need the Acrobat SDK to do so, which would probably not work for you with your restriction on downloading.

So you will have to use VBA to "print" to the PDF printer. Unfortunately this will still present you with a dialog for file names.

 
Hi Mintjulep,
thanks for your reply.

Sudakov.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top