Problem> prints first page twice from vba

  • Thread starter Thread starter CAA
  • Start date Start date
C

CAA

Hello
I have a macro attatched to a command button that does this:

Private Sub CommandButton5_Click()
Application.Dialogs(xlDialogPrint).Show
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
If sht.Range("a7").Value <> "" Then sht.PrintOut Copies:=1
Next
End Sub

For some reason it prints the first page twice, anybody know how t
just print the pages i need?

Thanks for looking
CA
 
Remove the
Application.Dialogs(xlDialogPrint).Show

Because
If sht.Range("a7").Value <> "" Then sht.PrintOut Copies:=1
is doing all you need, unless you have other requirements, like printing a
selected range
 
I need the 'Application.Dialogs(xlDialogPrint).Show' line to select th
printer from the network,
I have tried pinpointing the printer in code but it turns out to be
different one one each users computer.. what a headache.
Is there a piece of code where i just select the printer rarther tha
start printing when the 'Application.Dialogs(xlDialogPrint).Show' bo
is called.?

CA
 
Maybe you could just show a different dialog:

Application.Dialogs(xlDialogPrinterSetup).Show

And just to stop killing trees while you're testing:

If sht.Range("a7").Value <> "" Then sht.PrintOut preview:=True, Copies:=1
 
Back
Top