Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Printer Names on a Network Corey[_3_] Excel Programming 5 December 2nd 08 01:36 PM
Available Printer names to be placed in a range on a sheet and Force selection based on part of Printer name Corey Excel Programming 0 October 3rd 08 01:27 AM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Selecting a Printer on a network Dave Peterson Excel Programming 1 January 24th 07 08:23 PM
selecting network printer Bill Kuunders Excel Programming 0 January 11th 05 08:22 PM


All times are GMT +1. The time now is 04:23 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"