Do not print if error

  • Thread starter Thread starter Edgar
  • Start date Start date
E

Edgar

Hi

I have the following code which saves an invoice to my hd
and then prints it.

Is it possible for the macro to stop if the invoice
already exists on my hard disk?

Sub MetroparkPrint()

' MetroParkPrint Macro
' Macro to save and then print an invoice

ActiveWorkbook.SaveAs ("c:\Metropark\" & Range("j10")
& ".xls")

With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 80
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub

Thanks

Edgar
 
Sub MetroparkPrint()
Dim sName as String
' MetroParkPrint Macro
' Macro to save and then print an invoice
sName = "c:\Metropark\" & Range("J10") & ".xls"
if dir(sName) <> "" then exit sub
ActiveWorkbook.SaveAs sName

With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 80
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top