"Microsoft Print to PDF" Default Output Folder

A recap of what I discovered while trying to set the default save folder for the "Microsoft Print to PDF" driver using VBA in Access.

"Microsoft Print to PDF" Default Output Folder
How do you set the default output folder for the "Microsoft Print to PDF" virtual print driver using VBA in Access?

That's essentially the question a colleague asked me today.

Bottom line? I feel like I got about 80% of the way to a solution, but there's still some work to do.

That said, I did a bunch of valuable research that either:

  • A.) Someone else can use as a starting point to arrive at a full solution; OR
  • B.) I can come back to and finish some time in the future.

Recap

Without further ado, here's a summary of what I learned (summarized with the help of ChatGPT-4o-Latest):


Here’s a concise recap of what I learned so far regarding setting the default output folder for the Microsoft Print to PDF virtual printer in MS Access:


Key Findings:

  1. No Direct Way to Set the Default Folder:
    • There is no direct mechanism in VBA (or Windows in general) to programmatically set the default output folder for the Microsoft Print to PDF virtual printer.
  2. Application-Specific Folders:
    • The default export folder is specific to the application. For example:
      • Printing to PDF from Notepad used one folder.
      • Printing to PDF from Access used a different folder.
      • Returning to Notepad after printing from Access reverted to the original folder used in Notepad.
  3. Session-Specific Behavior:
    • The default folder is likely session-specific, meaning it could reset between different runs of the application. Although I didn't test this specifically, it's a reasonable assumption based on observed behaviors.
  4. Not Stored in the Windows Registry:
    • Using ProcMon (a low-level Windows utility), I confirmed that the default folder setting is not written to or read from the Windows Registry.
  5. File Export in VBA Affects the Print to PDF Folder:
    • Performing a file export of a VBA object (via File > Export File…) does update the default folder used by the "Save Print Output As" dialog for the Print to PDF driver.
  6. DoCmd.TransferText Does Not Affect the Folder:
    • While the DoCmd.TransferText function successfully exports data, it does not affect the default folder for the Print to PDF dialog.
  7. Potential for a Dummy Export:
    • There may still be a way to perform a dummy export from VBA that updates the default folder for the Print to PDF driver, but this would require further testing to identify the correct method.
  8. CurDir() Does Not Reflect the Print to PDF Folder:
    • The CurDir() function does not return the folder that will be used by the Print to PDF driver. While it could coincidentally align with the Print to PDF default folder (especially if both default to a common directory like the user's Documents folder), this is not guaranteed.
  9. ChDrive and ChDir Cannot Set the Print to PDF Folder:
    • Since CurDir() does not correspond with the Print to PDF folder, using ChDrive and ChDir to change the current directory does not set the default folder for the Print to PDF dialog either. This was confirmed through testing.

Final Summary:

The default folder for the Microsoft Print to PDF driver can be indirectly influenced through various user interactions in Access, such as performing a manual export. However, I was unable to find a purely programmatic way to set this folder via VBA. That said, there remains a decent chance that a programmatic workaround exists (possibly through a dummy export or some other action), but further investigation and testing would be required to identify it.

Acknowledgements
  • Cover image generated by FLUX-Schnell

All original code samples by Mike Wolfe are licensed under CC BY 4.0