Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2010 - Change printer depending on choice

Status
Not open for further replies.

dvirgint

Programmer
Jun 28, 2010
85
0
0
CA
Hello,

I've made a macro which scrapes information from Extra! Attachmate. The information is then printed onto a form which is located in one of three trays in a printer. One of the pieces of information is the person's language (Ex. 'English', 'French', 'Spanish'), and this information is stored in abreviation form, such as 'EN', 'FR' and 'SP'.

From what I've read, the easiest way to have a macro print to a specific tray is to create a separate printer for each tray and then change the default printer depending on the tray needed.

I have 3 .INF files set up which contain network printer addresses and I use the following code to get the macro to select the printer depending on the language, so for the sake of time and space, I'll include the code for the English part:

The English .INF contains:

\\SERVER1\Lexmark [highlight]on Ne03:[/highlight]

And the code goes like this:

Code:
'STDprinter = Application.ActivePrinter
'If tpLang = "EN" Then
'    ConfigFile$ = "T:\SERVER\\Macros\Printer1.inf"
'    If Dir$(ConfigFile$) <> "" Then
'        Open ConfigFile$ For Input As #1
'        Line Input #1, PrinterName$
'        Close #1
'        Application.ActivePrinter = PrinterName$
'    Else
'        STDprinter
'    End If
            
'    Worksheets("Print").Select
'    ActiveSheet.PageSetup.PrintArea = "$A$1:$AL$28"
'    ActiveSheet.PrintOut  
'Elseif ...
'End If

'Application.ActivePrinter = STDprinter
'Workbooks("INNS.xls").Close SaveChanges:=False

My problem is with the printer name itself. You'll notice that the printer name has a "on Ne03:" at the end. This seems to change from time to time depending on the computer it is being used on. Does anyone know how to standardize this, or to simply remove it?

Thanks for your help.
dvirgint
 

hi,

Please post VBA question in forum707.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top