Printing Multiple Word Documents to a Single PDF
Submitted by Ken Puls on Mon, 2008-01-21 20:11. PDF | Word - VBAIntroduction:
This article contains code which will print all open Word documents into a single PDF file.
These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should also be noted that the example in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read my article on Early vs Late binding.
Print To PDF Using Microsoft's PDF/XPS Add-in
Submitted by Ken Puls on Thu, 2008-01-03 22:50. Excel - VBA | General VBA & Programming | PDFIntroduction:
This article contains code that can be used to print worksheets or entire workbooks to a PDF file, using Microsoft's free Save as PDF or XPS add-in for Office 2007. These routines will NOT work in versions of Office prior to 2007. If you are running an earlier version of Office, and are running on Windows XP, then have a look at my PDF Creator articles.
Versions Tested:
These routines have been tested successfully using the following versions of the software:
Error Messages: User-Defined Type Not Defined
Submitted by Ken Puls on Thu, 2007-03-01 21:43. Excel - VBA | General VBA & Programming | PDFThere are a great many errors that we can run into when programming, and just on of those is a Compile Error, specifically "User-Defined Type Not Defined".

This error could mean one of a few different things, which may not all be listed here. Two of the most common, however, are:
1. You are trying to create your own Constants and did not declare the Enum.
For an example of this, see my article on Creating Your Own Constants For Functions
2. You are automating an external program, (using Early Binding,) and forgot to set a reference to the required library.
Error Messages: Can't Initialize PDFCreator
Submitted by Ken Puls on Mon, 2007-02-19 21:52. Excel - VBA | General VBA & Programming | PDFA problem than can occur when working with PDFCreator via code is that sometimes the code releases PDFCreator too early, and it isn't properly closed.
What is happening?
At the end of the PDFCreator routines on this site, we release PDFCreator with (a variation of) the following line:
Set pdfjob = Nothing
As long as the PDFCreator.exe task is (still) running, we'll get the error "Can't initialize PDFCreator." every time we try to run the PDF creation code:

So if you're seeing the above error, the issue is that a PDFCreator process is running on your system. If you opened PDFCreator manually, you may not have closed it. Or, if you had previously run a PDFCreator routine, then it had not finished doing what it needed to do, so the process that was actually running on the system stayed alive. We can check this by going into the Task Manager, (right click the taskbar and choose Task Manager,) and verifying that a PDFCreator.exe task is running.
Printing Access Reports To A PDF File
Submitted by Ken Puls on Thu, 2006-09-28 18:30. Access - VBA | PDFIntroduction:
This article contains code examples to print a Microsoft Access report to a PDF file.
This code examples is built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should also be noted that this code example uses an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.
Print To Picture Using PDFCreator
Submitted by Ken Puls on Fri, 2006-06-23 21:29. Excel - VBA | General VBA & Programming | PDFIntroduction:
This article contains code examples to print worksheets to PDF files in a picture format, including: pdf, png, jpg, bmp, pcx, tif, ps (postscript), eps and txt
This code example is built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should also be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.
Resetting PDFCreator Options via Code
Submitted by Ken Puls on Fri, 2006-06-23 21:12. Excel - VBA | General VBA & Programming | PDFIntroduction:
This article contains code examples to reset some (but not all) of the default settings of PDFCreator.
These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.
Some Notes On Developing With PDFCreator
Submitted by Ken Puls on Wed, 2006-06-14 13:10. Excel - VBA | General VBA & Programming | PDFDuring my course of experimenting with PDFCreator, I ran into a few interesting things. In an effort to help any of you who decide to adapt this to your own use, I thought I'd share those here.
Getting the right download package
All of the code samples provided on the site were tested successfully using PDFCreator 0.9.1, GPLGhostscript.exe download package. Excel versions tested include:
- Excel 2003
- Excel 2007
I did, however, encounter some issues when testing using the AFPL version of the download package. Specifically, setting the encryption to 128 bit created a file that was corrupted. Personally, I'd just avoid that version, and stick with the GPL version.
Using PDFCreator with security options set
Submitted by Ken Puls on Fri, 2006-06-09 14:03. Excel - VBA | General VBA & Programming | PDFMacro Purpose:
To use PDFCreator to make a PDF that leverages some of their security features. Specifically, we'll create a file that uses:
- A "File open" password
- 128 bit encryption
- Preventing content copying
- Preventing modification
- Preventing printing
These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
Printing Worksheets To A PDF File (Using Early Binding)
Submitted by Ken Puls on Mon, 2006-04-10 23:00. Excel - VBA | PDFIntroduction:
This article contains code examples to print worksheets to PDF files.
These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should also be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.


