Page setup in reports

  • Thread starter Thread starter Lionel Fridjhon
  • Start date Start date
L

Lionel Fridjhon

I have the following event procedure that occurs when
the user presses the command button "cmdRunReport":

Private Sub cmdRunReport_Click()
Dim Response As Integer

Response = MsgBox("Set the parameters for
printing before proceeding - selection of printer, " &
vbCr & _
"print quality, number of copies,
paper used, etc." & vbCr & _
"Press 'OK' to continue, 'Cancel'
to abort", vbOKCancel, "PRINTER SETTNGS")
If Response = 2 Then Exit Sub
DoCmd.OpenReport ("rptInventory"), acViewPreview
End Sub

I would like to be able to incorporate the page setup
dialog box in the procedure instead of the message box.
Alternatively, can I write the procedure in much the same
way as I can specify all parameters for printing in Excel
VB (Printer select, quality of printing, etc).

Example:

With PageSetup
.PrintTitleRows = "$1:$6"
.PrintTitleColumns = "$A:$A"
End With

With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
Application.ActivePrinter = "EPSON Stylus Photo 825
on Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1,
ActivePrinter:= _
"EPSON Stylus Photo 825 on Ne01:", Collate:=True

ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Preview:=False


I also don't need the preview, as my Epson printer gives
me one automatically.

Can you help?

Lionel
 
Lionel,

Does this do what you want?...

DoCmd.OpenReport "rptInventory", acViewPreview
DoCmd.SelectObject acReport, "rptInventory"
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "Agent Addresses"

- Steve Schapel, Microsoft Access MVP
 
Back
Top