PDF page sizes - Access just won't let me choose! (1 Viewer)

ontopofmalvern

Registered User.
Local time
Today, 14:52
Joined
Mar 24, 2017
Messages
64
Hi

I have db that produces my school's timetable, we are a specialist school and it changes a lot (almost weekly, it drives me nuts). Each time I make an amend I have a button that I press to output all the timetable documents (of which there are over 100) to PDFs on a shared drive, some are A3 and some are A4.

In the on-load event of each report, I have a bit of code that looks a bit like this>-

Code:
    Me.Printer.PaperSize = acPRPSA3
    Me.Printer.Orientation = acPRORLandscape
    Me.Printer.BottomMargin = 0.1 * 1440
    Me.Printer.TopMargin = 0.1 * 1440
    Me.Printer.LeftMargin = 0.1 * 1440
    Me.Printer.RightMargin = 0.1 * 1440

The 'PaperSize' and '.Orientation' vary according to the document.

The code that creates the PDF looks something like this

DoCmd.OpenReport Report, acViewReport, "", "", acNormal
DoCmd.OutputTo acOutputReport, Report, acFormatPDF, destinationPath & Trim(rst!staff_name) & ".pdf"
DoCmd.Close acReport, Report

(I run the OpenReport bit which I know is inefficient as in my experience it seems to force the OnLoad events to happen)


All works fine.. except...

I have 2 printers one of which is A4 only. If the currently selected Windows printer is the A4 only one, Access decides I can't make A3 PDF and helpfully splits it across multiple A4s. (all works fine if I have the A3 one selected - although if I run it from my home office I don't have an A3 printer so windows tends to tell my laptop to select my small home printer)

Apart from making sure the windows selected printer has A3 capability does anyone have a way to force Access to believe me when I say I want an A3 page? Is there a bit of code that for example that changes windows printer to "Microsoft Print to PDF" which will be present on whatever PC I run the code on, where ever I am?

Many thanks, Richard.

(incidentally, if I were starting again they would all be A4 and I would scale them onto A3 when printed - page sizing in Access has always frustrated me.)
 

KitaYama

Well-known member
Local time
Today, 23:52
Joined
Jan 6, 2022
Messages
1,489
Is there a bit of code that for example that changes windows printer to "Microsoft Print to PDF"
The following code changes OS default printer.
You need a Windows Script Host Object Model reference or late bind it.

Code:
Dim W As New WshNetwork
W.SetDefaultPrinter ("Microsoft Print to PDF")
 

ontopofmalvern

Registered User.
Local time
Today, 14:52
Joined
Mar 24, 2017
Messages
64
Yep, that seems to work. Many thanks.
 

Users who are viewing this thread

Top Bottom