Office Settings & Configuration

Save Microsoft Access Reports to a Dynamic Folder with VBA

Amos GikundaAmos Gikunda Nov 14, 2026 868 views

Question details

Export Access reports to a folder beside the current database, creating the folder if it does not exist.

Save Microsoft Access Reports to a Dynamic Folder with VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
A VBA procedure needs to save financial reports in a Monthly Financial Reports folder without relying on a fixed directory path.
Observed behavior
Reports should be exported to a folder relative to the current database, with the folder created when needed.
Before you start

Open the Access database and identify the report name and desired output filename. Make sure you have permission to create folders and files in the directory containing the database.

Solution 1Recommended

Create a Database-Relative Folder and Export the Report

Use the current database path to locate or create the export folder before saving a report as a PDF.

Application.CurrentProject.Path returns the folder containing the current database. Dir checks whether the export folder exists, and MkDir creates it when needed.

1
Open the VBA editor

In Access, press Alt+F11, then choose Insert > Module to add a standard VBA module.

2
Add the export procedure

Paste this procedure into the module: Public Sub ExportFinancialReport() Dim exportFolder As String exportFolder = Application.CurrentProject.Path If Right(exportFolder, 1) <> "\" Then exportFolder = exportFolder & "\" End If exportFolder = exportFolder & "Monthly Financial Reports" If Dir(exportFolder, vbDirectory) = "" Then MkDir exportFolder End If DoCmd.OutputTo acOutputReport, "YourReportName", acFormatPDF, _ exportFolder & "\FinancialReport.pdf", False End Sub

3
Set the report and filename

Replace YourReportName with the name of your Access report and FinancialReport.pdf with the PDF filename you want. Repeat the DoCmd.OutputTo line with different report names and filenames to export additional reports.

4
Run and check the export

Place the cursor inside ExportFinancialReport and press F5. Open the Monthly Financial Reports folder beside the database and check that the PDF was created.

Create a Database-Relative Folder and Export the Report
Check the destination: The database directory must be writable, and a file with the same name as the intended folder can prevent folder creation. Use distinct PDF filenames if you need to retain separate exports.
Free Microsoft Office alternative

Work with Financial Reports in WPS Office

WPS Office is a free, lightweight alternative for working with documents and spreadsheets in a familiar interface. Its Microsoft Office format compatibility helps you move existing files into WPS, although it does not run Access VBA or replace an Access database.

Review and edit financial report data in WPS Spreadsheets.Open and save compatible Microsoft Excel files, including XLSX.Use a familiar interface for everyday document and spreadsheet work.Create PDFs from supported documents for sharing.
microsoft office alternative - wps office

Frequently Asked Questions

Where will Access create the Monthly Financial Reports folder?

The folder is created inside the directory returned by Application.CurrentProject.Path, alongside the current database file.

What happens if the export folder already exists?

The Dir check finds the folder, so the procedure skips MkDir and exports the report to the existing folder.

How do I export more than one Access report?

Add another DoCmd.OutputTo line after the folder check for each report. Set the report name and use a distinct output filename for each PDF.

Why might the folder or PDF fail to be created?

Check that you can write to the database directory, that the report name in DoCmd.OutputTo is correct, and that a file with the intended folder name does not already exist.

Can WPS Office run this Access VBA procedure?

No. Run the procedure in Microsoft Access. WPS Office can instead help you work with compatible documents and spreadsheets exported from your workflow.