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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Word documents to PDF via Access VBA

Status
Not open for further replies.

vbajock

Programmer
Jun 8, 2001
1,921
US
I use the nifty little dynapdf.dll for converting Access snapshots into PDFs, but I have an app that constructs a Word document via code from data in the database, and then attaches it to an email and sends. Now the user wants it sent in PDF format like all the rest of the reports. Does anyone know of a utility that can be called from code that will convert a Word doc to a pdf?

Thanks!
 
We use PDF995.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I use CutePDF to print to a PDF - yet another freebee

However, I'd be interested to see if someone has a solution for doing this in code so a use could just click a button and then access would bring up a save ass dialog, or better yet, an email message.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
You can do all of that with dynappdf, go to Lebans.com for the free download, has pre-written code and example mdbs. The problem is it only seems to work with Access reports, I cannot find any documentation to use it for Word docs.
 
Ok PHV, I installed PDF995, do you have any sample code on how you use it? There does not seem to be a lot of documentation.

 
For what it's worth when I used it I wasn't a big fan of PDF995. Nothing specific... The version I used prompted to save but it has been a long time, maybe they fixed it.

CutePDF will prompt you to save the file (bad). I believe Bullzip took over the PDFCreator GNU project (whish is good and could be configured to save to a file automatically) so bullzip probably is good. And I don't know a thing about dynapdf.

Also, if you have Office 2007 there is a print to PDF add-in. I've only barely used any office 2007 product and haven't had a chance to try it out or figured out how to do it programatically.

 
I couldn't resist, I D'L'd the office 2007 add in and recorded a macro in word...


Code:
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
        "C:\Temp.pdf" _
        , ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
    ShowVisualBasicEditor = True

I didn't bother to uncheck the option for opening the PDF when done... So a read through the help topic is probably in order if you are going down this path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top