Passing a file name to PDF Printer

S

Stu

Hello

I'm trying to write a macro in Word 2003 that will print individual PDF
files for each record in a mail merge, with the file name being sourced from
a field in the data source. I can capture the value OK (checked via a
temporary MsgBox) but I'm having no success in trying to pass that value to
the dialog box for the PDF printer (in the current case, Jaws PDF Creator).

The menu command installed by Jaws invokes a custom-installed macro as
Application.Run MacroName:="JawsPdfCreator.CreatePDF.CreateJawsPdfFile"

That opens the dialog box with the filename of the active document
highlighted - what I want to do is replace the highlighted value with the
filename I create from the source data field.

SendKeys doesn't work (it regards the active document as the active object,
and types it in there), and I don't know enough about the Jaws DDE stuff to
use the DDE commands.

Any help or clues would be mightily appreciated

Stu
 
D

Doug Robbins - Word MVP

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's website
at:

http://www.gmayor.com/individual_merge_letters.htm

If you are using Word XP or later, the work has all been done for you in the
"Add-in to Merge Letters to Separate Files" that I have written and that can
be downloaded from that site will allow you to create each letter as a
separate file with a filename taken from a field in the data source with a
minimum of fuss, plus create the output as .pdf files.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

Stu

Doug, it looks just the berries!

I'll run a couple of tests and post an outcome.

Thanks a million.

Stu
 
S

Stu

Hello again Doug

Two problems:

1. It doesn't work with Jaws PDF Creator, even if I replace "Adobe PDF"
with "Jaws PDF Creator" (which is the name Word seems to recognise when I
record a macro to change the printer to that) in the code under Private Sub
app_MailMergeAfterMerge. Is there any way to allow it to work with Jaws, or
is it "Adobe-particular"?

2. When I run it without selecting the Create PDFs option, it creates the
individual documents, but comes up with Run-time error '91' - Object variable
or With block variable not set. Going to debug has it pointing at the one
line of code in Sub DeleteResultsDocument(). I'm left with an empty
"FormLetters" document on screen.

Stu
 
G

Graham Mayor

The problem with clone PDF creators is attributable to the way that they
create PDF filenames. eg If you have Snagit 8 then its driver can create
PDFs, but it will not automatically name them from the source. In the case
of the SnagIt driver, if you substitute that for the Adobe PDF driver then
the chances are that it will create the same error message.

With SnagIt 8, you can set it to automatically name the PDF files. If you do
this the add-in will create named doc files in the target location and
automatically named PDF files which do not carry the same name sequence as
the merged documents. I suspect that Jaws PDF creator works in a similar
way. The Adobe driver is rather more configurable,.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Forgot to mention that if the field you use to name the documents contains
illegal filename characters, you will also get an error.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Stu

Hello Graham

Mmm.. familiar with the issue - Jaws does give you configurable options -
"Always/Never request Destination" and to include a default folder. That's
if "save to PDF" is selected - and it's always the filename of the current
document (if it already exists, it appends a serial number.) If the Jaws PDF
Creator is selected as the printer, it always requests a file name in the
dialog box.


In this instance, the file name I want to/have to assign will always be a
customerID - always an integer number cast as a string - followed by a date
code, as 12345_20070219. That code is created within our database and is a
field in the merge source document.

Will do some more playing - and maybe have to go and buy Adobe8!

Thanks

Stu
 
G

Graham Mayor

If you can 'print' to the Jaws driver, and you can setup the driver to
automatically assign the filename from the document then as the add-in saves
each document then 'prints' it to the PDF driver, you might be able to coax
it to work. The only non-Acrobat driver I have used it with has been SnagIt
which works with the provisos already made. Doug wrote the code (I only did
some testing and provide the web host for the file) so he may know of other
drivers that have been tested with it. I seem to recall that at least one
other clone has been used. I hear that the freebie PrimoPDF may not work
(though I am currently downloading it to test).

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Actually PrimoPDF works fine with two provisos. You get a prompt for each
record. In answer to the first prompt you change the destination path (but
not the file name). Then OK each record thereafter. A pain if it's a big
data file :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

Michael Bednarek

I'm trying to write a macro in Word 2003 that will print individual PDF
files for each record in a mail merge, with the file name being sourced from
a field in the data source. I can capture the value OK (checked via a
temporary MsgBox) but I'm having no success in trying to pass that value to
the dialog box for the PDF printer (in the current case, Jaws PDF Creator).

The menu command installed by Jaws invokes a custom-installed macro as
Application.Run MacroName:="JawsPdfCreator.CreatePDF.CreateJawsPdfFile"

That opens the dialog box with the filename of the active document
highlighted - what I want to do is replace the highlighted value with the
filename I create from the source data field.

SendKeys doesn't work (it regards the active document as the active object,
and types it in there), and I don't know enough about the Jaws DDE stuff to
use the DDE commands.

PDFCreator comes with a COM interface, offering much the same
flexibility and programmability as Adobe Acrobat does - no dialogue
boxes and no SendKeys necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top