Decline Save

B

Basta1980

Hi,

I have a PrintToFile statement telling Excel to save a worksheets as Tiff
document. When the procedure is triggered a pop-up box appears in order to
let the user define filename. This works fine. But when the user doens't
wan't to save a copy and simply presses 'cancel' he/she gets a runtime error
1004 Method PrintOut of object Worksheet failed. How do I programme the
procedure in order to not show the error.

Sheet1.PrintOut ActivePrinter:="Microsoft Office Document Image Writer", _
PrintToFile:=True, _
PrToFileName:="\\Nlmtr-wifs001\CSBUSSE\Data
Services\SSV\Netwerkklachten\Overige Info\weekoverzichtenbrieven\Status
Workload SSV " & _
DatePart("yyyy", ThisMonday - 1) & " week " &
DatePart("ww", ThisMonday - 1, vbMonday, vbUseSystem) & ".mdi"

Gr.

Basta
 
S

Simon Lloyd

Use some error handling something like:

Code:
--------------------

On Error Goto Nxt
Sheet1.PrintOut ActivePrinter:="Microsoft Office Document Image Writer", _
PrintToFile:=True, _
PrToFileName:="\\Nlmtr-wifs001\CSBUSSE\Data
Services\SSV\Netwerkklachten\Overige Info\weekoverzichtenbrieven\Status
Workload SSV " & _
DatePart("yyyy", ThisMonday - 1) & " week " &
DatePart("ww", ThisMonday - 1, vbMonday, vbUseSystem) & ".mdi"
Nxt:
'rest of your code

--------------------

Basta1980;367553 said:
Hi,

I have a PrintToFile statement telling Excel to save a worksheets as
Tiff
document. When the procedure is triggered a pop-up box appears in order
to
let the user define filename. This works fine. But when the user
doens't
wan't to save a copy and simply presses 'cancel' he/she gets a runtime
error
1004 Method PrintOut of object Worksheet failed. How do I programme the
procedure in order to not show the error.
Code:
--------------------
Sheet1.PrintOut ActivePrinter:="Microsoft Office Document Image Writer", _
PrintToFile:=True, _
PrToFileName:="\\Nlmtr-wifs001\CSBUSSE\Data
Services\SSV\Netwerkklachten\Overige Info\weekoverzichtenbrieven\Status
Workload SSV " & _
DatePart("yyyy", ThisMonday - 1) & " week " &
DatePart("ww", ThisMonday - 1, vbMonday, vbUseSystem) & ".mdi"
--------------------
Gr.

Basta


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
H

Howard31

Hi Basta,

Put the following statement before the first line of code:

On Error Resume Next

This should help
 
Top