Solved

Access 2010 Print PDF from file - Shrink A3 to A4

Posted on 2012-03-25
5
1,580 Views
Last Modified: 2012-09-30
I have a print option the prints a job sheet from access and then prints a list of files listed on the job. I have used the Shell Execute to print these if they are PDF's:-

Call ShellExecute(Application.hWndAccessApp, "print", strfilepath, "", "", 0)

This all works fine however some of the files are in A3 format and only have A4 in the tray so only prints part of the page.

If you open the PDF and print (Ctrl P) and you choose Fit to Printable area or Shrink oversized pages they print on A4 OK. (Obviously smaller size but this is OK)

Is there any way I can pass this print property to the printer so A3 prints on A4 paper?.
0
Comment
Question by:donhannam
5 Comments
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 37766493
You could define a printer object to use A4 paper, and then use the following code (or some variation of it) to temporarily change the default printer so that your Shell code uses the A4 printer:

Public Sub PrintToSpecificPrinter(strPrinter As String, strReport As String)
'Created by Helen Feddema 12-Feb-2010
'Last modified by Helen Feddema 12-Feb-2010

On Error GoTo ErrorHandler

   Dim prtCurrent As Printer
   Dim prtDefault As Printer
   
   'Save current default printer
   Set prtDefault = Application.Printer
   Debug.Print "Current default printer: " & prtDefault.DeviceName
   
   'Select a specific printer as new default printer
   Application.Printer = Printers(strPrinter)
   
   'Print the report
   DoCmd.OpenReport strReport
   
   'Set printer back to former default printer
   Application.Printer = prtDefault
      
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & _
      Err.Description
   Resume ErrorHandlerExit

End Sub

================================

Public Function ListPrinters()
'Lists Access printer names as used in VBA code
'to the Immediate window
  
   Dim prt As Access.Printer
   
   For Each prt In Application.Printers
      Debug.Print prt.DeviceName
   Next prt
   
End Function

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37766499
Not with ShellExecute...

Access will typically store this info for each report.
So it would seem that you would have to create some fairly complex code to read that setting, then dynamically change the printer properties.

Either that, or print the A3 and A4 reports separately...

Let's see what other experts may post....

JeffCoachman
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 37766508
Are you actually creating the PDFs from Access, or printing PDF files which may or may not have been created from Access?  If you are creating the PDFs directly from Access, you can use this syntax instead of the Shell command:

   DoCmd.OutputTo objecttype:=acOutputReport, _
      objectname:=strReport, _
      outputformat:=acFormatPDF, _
      outputfile:=strPDFFile

Open in new window

0
 
LVL 10

Accepted Solution

by:
LukeChung-FMS earned 500 total points
ID: 37766579
FYI, if your Microsoft Access database is compiled in an MDE, ADE or ACCDE, you can't change the paper size of a report programmatically via VBA. You'll need to keep a separate copy of the report for each paper size and output the appropriate one.
0
 

Author Comment

by:donhannam
ID: 37768921
Thanks for the comments - to clarify I am not creating a report or PDF in access just wanting to print a PDF that is stored in a file. After printing a job sheet I also want to print some drawings which are stored on server. I record the file path in access and to print use the above shell execute command to print.

Helen - looks like there may be some way to temporarily change the default printer properties and then set these back. I had a look at the printer properties and there is a "Fit to Size property on my printer'. However when set the default to this and I open a page in Adobe reader and print it does not use this - need to set "Shrink Oversized pages" in Adobe print dialog.

Not sure if there is any way to change the print settings for Adobe reader?.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now