Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Do not print if error

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Do not print if error

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

--
Regards,
Tom Ogilvy

"Edgar" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error created when try to Print Preview or Print Nadine Excel Discussion (Misc queries) 0 June 1st 10 10:08 PM
Print Error Message: Print titles must be contiguous and complete sum1029 Excel Discussion (Misc queries) 1 September 16th 09 07:27 PM
Excel spreadsheet print preview error "nothing to print" ann Excel Discussion (Misc queries) 8 August 23rd 06 08:58 PM
Why do I get a print error light trying to print an excel sheet ? SMC Excel Discussion (Misc queries) 2 November 5th 05 01:36 AM
print error jack loyen Excel Discussion (Misc queries) 0 January 26th 05 11:10 AM


All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"