ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SetActivePrinter (https://www.excelbanter.com/excel-programming/292313-setactiveprinter.html)

The One

SetActivePrinter
 
Hi All,

I am trying to ensure that users use print to a pre-set printer (in the
registry) usng Excel. I get the printer name as follows:

CPrintDialog dlg(true);
if( dlg.DoModal() != IDOK)
return false;

CString sPrinter = dlg.GetDeviceName();
// sPrinter = "hp officejet g series"

I then write the string into the registry. THis all works fine.

In Excel I call

app.SetActivePrinter(m_sPrinter);

and I get an error because, using app.GetActivePrinter() returns
"hp officejet g series on Ne03:"

Can anyone tell me how I get the name show by GetActivePrinter()?

TIA
JohnTheOne

Ko Vijn[_3_]

SetActivePrinter
 
Try this, works with me.

MySecondPrinter = "Lexmark Z25-Z35 on Ne00:"' 'USB printer
MyFirstPrinter = "HP LaserJet 1100 (MS) on LPT1:" 'on LPT1:

application.ActivePrinter = MySecondPrinter
application.ActivePrinter = MyFirstPrinter

You may find out yourself through your macrorecorder, which returned
something like

Application.ActivePrinter = "HP LaserJet 1100 (MS) on LPT1:"
Selection.PrintOut Copies:=1, ActivePrinter:= _
"HP LaserJet 1100 (MS) on LPT1:", Collate:=True

Note the word 'op' is language sensitive


"The One" schreef in bericht
.. .
Hi All,

I am trying to ensure that users use print to a pre-set printer (in the
registry) usng Excel. I get the printer name as follows:

CPrintDialog dlg(true);
if( dlg.DoModal() != IDOK)
return false;

CString sPrinter = dlg.GetDeviceName();
// sPrinter = "hp officejet g series"

I then write the string into the registry. THis all works fine.

In Excel I call

app.SetActivePrinter(m_sPrinter);

and I get an error because, using app.GetActivePrinter() returns
"hp officejet g series on Ne03:"

Can anyone tell me how I get the name show by GetActivePrinter()?

TIA
JohnTheOne




The One

SetActivePrinter
 
Hi Ko Vijn,

thank you for the suggestion but I do not know the nae of the printer
until run time. I am trying to get the exact name of the printer from
the CPrintDialog but it does not return the " on Ne00:" or " on LPT1:"
which is what Excel returns in the app.GetActivePrinter() call.

Anyone got any other ideas ???

John

"Ko Vijn" wrote in
:

Try this, works with me.

MySecondPrinter = "Lexmark Z25-Z35 on Ne00:"' 'USB printer
MyFirstPrinter = "HP LaserJet 1100 (MS) on LPT1:" 'on LPT1:

application.ActivePrinter = MySecondPrinter
application.ActivePrinter = MyFirstPrinter

You may find out yourself through your macrorecorder, which returned
something like

Application.ActivePrinter = "HP LaserJet 1100 (MS) on LPT1:"
Selection.PrintOut Copies:=1, ActivePrinter:= _
"HP LaserJet 1100 (MS) on LPT1:", Collate:=True

Note the word 'op' is language sensitive


"The One" schreef in bericht
.. .
Hi All,

I am trying to ensure that users use print to a pre-set printer (in
the registry) usng Excel. I get the printer name as follows:

CPrintDialog dlg(true);
if( dlg.DoModal() != IDOK)
return false;

CString sPrinter = dlg.GetDeviceName();
// sPrinter = "hp officejet g series"

I then write the string into the registry. THis all works fine.

In Excel I call

app.SetActivePrinter(m_sPrinter);

and I get an error because, using app.GetActivePrinter() returns
"hp officejet g series on Ne03:"

Can anyone tell me how I get the name show by GetActivePrinter()?

TIA
JohnTheOne






All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com