A family of Microsoft relational database management systems designed for ease of use.
May still be done as a report.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have created a Word document which has a connection to a database table with all fields defined in the document.
I have tried various ways to get Access VBA to open the document, automatically populate the data and save the Word document as a PDF file.
Does anyone have any code I could try please?
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
May still be done as a report.
You might like to take a look at AccWord.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
This little demo file illustrates a number of Access to Word automation operations. For merging the method used is to export the result table of a query to a delimited text file, which is then used as the source document for the merge.
If you are creating a single document, rather than merging a set of records to a set of word documents, you might like to consider inserting text at bookmarks in the Word template file. This is also illustrated in my demo.
The demo does not including saving a document as a PDF, but if you were to do as Scott suggests, and, rather than using Word, create an Access report, this becomes simple. The InvoicePDF.zip demo in my same OneDrive folder illustrates how to do this. If you do use Word, my AccWord demo does not include this, but I've just recorded the following VBA procedure, called a 'macro' in word, for doing so with a Word document of one of the invoices created by the InvoicePDF demo. This could be easily incorporated into my AccWord demo by passing the paths to the folder and file into the procedure as arguments, rather than hard coding them in the procedure:
Sub SaveAsPDF()
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"C:\Users\kenws\Documents\Databases\InvoicePDF\ACME Flange Company\ACME Flange Company 20111208103010.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
ChangeFileOpenDirectory _
"C:\Users\kenws\Documents\Databases\InvoicePDF\ACME Flange Company"
End Sub
Hi,
I have created a Word document which has a connection to a database table with all fields defined in the document.
I have tried various ways to get Access VBA to open the document, automatically populate the data and save the Word document as a PDF file.
Does anyone have any code I could try please?
Go to this link and search for "Super Easy Word Merge."
Hi Scott,
it is a fairly complicated 5 page application form.
Have you tried creating your form letter as an Access report?