The PDFCreator on SourceForge that Albert linked has done the job
perfectly. (I tried PDF995 but it has a pop up after each use which I
think would get a bit annoying after a while.) From within the
Options I could set whether to bypass the 'Save As' dialog or whether
to give the pdf file a std name or a sequential type name. It also
gives the option of whether to view the pdf straight away or attach to
an email. I've pasted my function at the bottom of this post in case
in case it helps.
I can now create pdf's of Word documents which have been merged with
data from the Access database. I have one last problem though, how to
apply a Word template to a Word document which is already open? The
original Word documents are printed on headed paper. When creating
the pdf, I need to recreate the headed paper layout with a header and
footer graphic. We could have two separate Word documents, one for
printing and one for pdf, but that would mean twice as much upkeep and
editing, then version issues and so on. It would be a lot cleaner to
just have one Word document to maintain. Is there a way to apply the
'pdf' template to the existing Word document and then I can send it to
the PDF printer?
Thanks again!
************************************************************************************************************************************
************************************************************************************************************************************
Public Function make_pdf()
' this function will take the word doc, merge it with merge.txt and
create a pdf called C:\letter-to-send.pdf
' check if C:\letter-to-send.pdf already exists, if so, delete it.
If Dir("C:\letter-to-send.pdf") <> "" Then
Kill "C:\letter-to-send.pdf"
End If
' open document in Word, merge data and send to pdf printer, then
reset the printer back to previous printer.
Dim ow As Word.Application
Dim x_doc As Word.Document
Dim x_current_printer As String
Set ow = CreateObject("Word.Application")
x_current_printer = ow.ActivePrinter
ow.ActivePrinter = "PDFCreator" ' PDFCreator printer is set up to save
to C:\letter-to-send.pdf
ow.Visible = False
Set x_doc = ow.Documents.Open("C:\letter.doc")
With x_doc.MailMerge
.OpenDataSource ("C:\merge.txt")
End With
With x_doc
.MailMerge.Destination = wdSendToPrinter
.MailMerge.Execute
End With
ow.ActivePrinter = x_current_printer ' resets the printer back to
previous printer.
ow.Documents.Close False
ow.Quit
End Function