Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
Hi
I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
post all of your code relating to this
-- Don Guillett SalesAid Software "libby" wrote in message ... Hi I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
Hi
Well, there are many networked printers in our office and I have created a form which has 5 of the most common ones in it. When the user selects one, a label displays the location of the printer in the office. I've also so set it so that if the Active Printer for a particular pc isn't in the listbox, then it's added to it. There is a "Change" button on the form which changes the active printer to one which the user has selected. It all works fine if you have all the printers mapped to your pc, but if you try and change the active printer to one which is not mapped to your pc, then the run-time error occurs. I need to either map the printer (which I don't think is possible) or trap this error and go to an error handler which displays an appropriate message. The code for the Change button is Application.ActivePrinter = listbox1.value I can post more code if need be, but don't have it to hand at present. -----Original Message----- post all of your code relating to this -- Don Guillett SalesAid Software "libby" wrote in message ... Hi I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
I think I'd just let them pick from one of their mapped printers using a builtin
dialog box: Application.Dialogs(xlDialogPrinterSetup).Show But if you know enough about the printers, you can connect them via your code. I saved this example from a post in the scripting newsgroups: Option Explicit Sub testme02() Dim WSH As Object Dim PrinterPath As String Dim PrinterDriver As String Set WSH = CreateObject("WScript.Network") PrinterPath = "\\printserver\printershare" PrinterDriver = "HP LaserJet 4050 Series PS" WSH.AddWindowsPrinterConnection PrinterPath, PrinterDriver WSH.SetDefaultPrinter PrinterPath End Sub libby wrote: Hi Well, there are many networked printers in our office and I have created a form which has 5 of the most common ones in it. When the user selects one, a label displays the location of the printer in the office. I've also so set it so that if the Active Printer for a particular pc isn't in the listbox, then it's added to it. There is a "Change" button on the form which changes the active printer to one which the user has selected. It all works fine if you have all the printers mapped to your pc, but if you try and change the active printer to one which is not mapped to your pc, then the run-time error occurs. I need to either map the printer (which I don't think is possible) or trap this error and go to an error handler which displays an appropriate message. The code for the Change button is Application.ActivePrinter = listbox1.value I can post more code if need be, but don't have it to hand at present. -----Original Message----- post all of your code relating to this -- Don Guillett SalesAid Software "libby" wrote in message ... Hi I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) . -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
On Error goto ErrHandler
Application.ActivePrinter = listbox1.value Exit Sub ErrHandler: msgbox err.number & vbNewLine & _ err.Description & vbNewline & vbNewLine & _ "This printer is not available" End Sub -- Regards, Tom Ogilvy libby wrote in message ... Hi Well, there are many networked printers in our office and I have created a form which has 5 of the most common ones in it. When the user selects one, a label displays the location of the printer in the office. I've also so set it so that if the Active Printer for a particular pc isn't in the listbox, then it's added to it. There is a "Change" button on the form which changes the active printer to one which the user has selected. It all works fine if you have all the printers mapped to your pc, but if you try and change the active printer to one which is not mapped to your pc, then the run-time error occurs. I need to either map the printer (which I don't think is possible) or trap this error and go to an error handler which displays an appropriate message. The code for the Change button is Application.ActivePrinter = listbox1.value I can post more code if need be, but don't have it to hand at present. -----Original Message----- post all of your code relating to this -- Don Guillett SalesAid Software "libby" wrote in message ... Hi I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
error trapping
Thanks guys!
-----Original Message----- On Error goto ErrHandler Application.ActivePrinter = listbox1.value Exit Sub ErrHandler: msgbox err.number & vbNewLine & _ err.Description & vbNewline & vbNewLine & _ "This printer is not available" End Sub -- Regards, Tom Ogilvy libby wrote in message ... Hi Well, there are many networked printers in our office and I have created a form which has 5 of the most common ones in it. When the user selects one, a label displays the location of the printer in the office. I've also so set it so that if the Active Printer for a particular pc isn't in the listbox, then it's added to it. There is a "Change" button on the form which changes the active printer to one which the user has selected. It all works fine if you have all the printers mapped to your pc, but if you try and change the active printer to one which is not mapped to your pc, then the run-time error occurs. I need to either map the printer (which I don't think is possible) or trap this error and go to an error handler which displays an appropriate message. The code for the Change button is Application.ActivePrinter = listbox1.value I can post more code if need be, but don't have it to hand at present. -----Original Message----- post all of your code relating to this -- Don Guillett SalesAid Software "libby" wrote in message ... Hi I'm having real trouble trapping this error. I have a sub where the active printer is changed Application.ActivePrinter = ListBox1.value if the printer is networked then it works fine, but if it isn't I get a run-time error 1004 Method 'ActivePrinter' of object'_Application' failed Is there any way I can user On Error GoTo Errorhandler to display the message "Printer Not Mapped" if this happpens? Thanks in advance Libby (xl97) . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Trapping | Excel Discussion (Misc queries) | |||
Trapping #VALUE! error | Excel Discussion (Misc queries) | |||
Error Trapping from WSH | Excel Discussion (Misc queries) | |||
error trapping | Excel Discussion (Misc queries) | |||
Remind me to set Error Trapping to Break on Unhandled Errors | Excel Programming |