Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
NetWork Printer Selection Problems
I need some assistance please with a network printer selection.
I use two network printers one colour the other non-colour and I need to print documents to both printers at different times during the day. The two printers are in different parts of the building. I currently use code to designate the printer required, such as: Application.ActivePrinter = "Colour Admin Office on Ne03:" ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _ "Colour Admin Office on Ne03:", Collate:=True Application.ActivePrinter = "Lexmark E323 on Ne02:" ' reverts back to non-colour The problem I have is that for some reason unknown to myself the Printer Name changes; for example from; "Colour Admin Office on Ne03 too "Colour Admin Office on Ne05" which caused an error when the routine is run. Without going down the route of asking the user to identify the Printer every time, is there a way using VB, to identify the correct printer based on the first part of the name? It only seems to be the last character that changes each time. Any help would be much appreciated Regards Lee |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
NetWork Printer Selection Problems
As long as the number is the only thing changing, I'd use something like:
Sub testme() Dim iCtr As Long Dim FoundIt As Boolean Dim CurPrinter As String CurPrinter = Application.ActivePrinter FoundIt = False For iCtr = 0 To 99 On Error Resume Next Application.ActivePrinter = "Colour Admin Office on Ne" _ & Format(iCtr, "00") & ":" If Err.Number = 0 Then FoundIt = True Exit For Else 'keep looking Err.Clear End If Next iCtr On Error GoTo 0 If FoundIt = False Then MsgBox "No printer close to that name" Else 'do the real work 'and change it back Application.ActivePrinter = CurPrinter End If End Sub leerem wrote: I need some assistance please with a network printer selection. I use two network printers one colour the other non-colour and I need to print documents to both printers at different times during the day. The two printers are in different parts of the building. I currently use code to designate the printer required, such as: Application.ActivePrinter = "Colour Admin Office on Ne03:" ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _ "Colour Admin Office on Ne03:", Collate:=True Application.ActivePrinter = "Lexmark E323 on Ne02:" ' reverts back to non-colour The problem I have is that for some reason unknown to myself the Printer Name changes; for example from; "Colour Admin Office on Ne03 too "Colour Admin Office on Ne05" which caused an error when the routine is run. Without going down the route of asking the user to identify the Printer every time, is there a way using VB, to identify the correct printer based on the first part of the name? It only seems to be the last character that changes each time. Any help would be much appreciated Regards Lee -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Printer Names on a Network | Excel Programming | |||
Available Printer names to be placed in a range on a sheet and Force selection based on part of Printer name | Excel Programming | |||
members on my network printer not able to print to default printer | Excel Discussion (Misc queries) | |||
Selecting a Printer on a network | Excel Programming | |||
selecting network printer | Excel Programming |