 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Uli Guest
|
Posted: Thu Jun 03, 2004 10:16 am Post subject: Excel-OLE: changing ActivePrinter |
|
|
I'm working/interacting with Excel using pure OLE-interface functionality
(like I posted already on 24.05.04)
I want to change the printer with
vExcelApp.OlePropertySet("ActivePrinter) szPrinterName);
Basically this works but there are some difficulties!
The Problem changing the active printer is, that you have to specify exactly
the same printer-setting-string (szPrinterName) like Excel would do this.
This means:
1. language-dependent
2. port-dependent
3. it may be, that the correct printer name varies from this shown in the
selection-list
For example:
(1.) "Acrobat Distiller auf Ne03:" / "Acrobat Distiller on Ne03:"
(2.) "Acrobat Distiller auf Ne03:" / "HP LaserJet 5100 PCL 6 auf NE00:" /
PostScript-Printer auf FILE:"
First I thought, that Ne## is the index of the printer in the
printer-selection-list. But this sucks, if there's installed a printer which
uses a file for printout (like the PostScript-Printer above) - then the
index numbers don't fit the port-nr.
So, how can I retrieve the correct string for printer-setting to make it
"well formed" for excel. Otherwise Excel throws an exception and the
printer-selection won't be done.
Has anyone an idea for this or knows another method to change the
ActualPrinter which Excel uses for a current print-out (without changing the
system's standard-printer)?
Thanks in advance,
Uli.
|
|
| Back to top |
|
 |
Jean-Marie Babet Guest
|
Posted: Thu Jun 03, 2004 5:14 pm Post subject: Re: Excel-OLE: changing ActivePrinter |
|
|
Uli,
If you search for "EnumPrinters" on Google (and maybe add 'Excel' and
'ActivePrinter'), you'll see some code that enumerates through printers and
returns their names. For example, the following links seem to do so:
http://www.eksperten.dk/spm/465980
http://word.mvps.org/FAQs/MacrosVBA/AvailablePrinters.htm
http://www.herber.de/forum/archiv/372to376/t373602.htm
The code targets Office Automation - hence, the language: VBA. However, the
logic seems simple to port to C++. I believe the relevant part is the calls
to EnumPrinters and then the formatting of the name.
Hope the above is useful.
Regards,
Bruneau.
"Uli" <nospam (AT) nospam (DOT) de> wrote
| Quote: | I'm working/interacting with Excel using pure OLE-interface functionality
(like I posted already on 24.05.04)
I want to change the printer with
vExcelApp.OlePropertySet("ActivePrinter) szPrinterName);
Basically this works but there are some difficulties!
The Problem changing the active printer is, that you have to specify
exactly
the same printer-setting-string (szPrinterName) like Excel would do this.
This means:
1. language-dependent
2. port-dependent
3. it may be, that the correct printer name varies from this shown in the
selection-list
For example:
(1.) "Acrobat Distiller auf Ne03:" / "Acrobat Distiller on Ne03:"
(2.) "Acrobat Distiller auf Ne03:" / "HP LaserJet 5100 PCL 6 auf NE00:" /
PostScript-Printer auf FILE:"
First I thought, that Ne## is the index of the printer in the
printer-selection-list. But this sucks, if there's installed a printer
which
uses a file for printout (like the PostScript-Printer above) - then the
index numbers don't fit the port-nr.
So, how can I retrieve the correct string for printer-setting to make it
"well formed" for excel. Otherwise Excel throws an exception and the
printer-selection won't be done.
Has anyone an idea for this or knows another method to change the
ActualPrinter which Excel uses for a current print-out (without changing
the
system's standard-printer)?
Thanks in advance,
Uli.
|
|
|
| Back to top |
|
 |
Uli Guest
|
Posted: Fri Jun 04, 2004 9:07 am Post subject: Re: Excel-OLE: changing ActivePrinter |
|
|
Thanks, I'll have a look.
Uli.
"Jean-Marie Babet" <bbabet (AT) borland (DOT) com> schrieb im Newsbeitrag
news:40bf5c63$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Uli,
If you search for "EnumPrinters" on Google (and maybe add 'Excel' and
'ActivePrinter'), you'll see some code that enumerates through printers
and
returns their names. For example, the following links seem to do so:
http://www.eksperten.dk/spm/465980
http://word.mvps.org/FAQs/MacrosVBA/AvailablePrinters.htm
http://www.herber.de/forum/archiv/372to376/t373602.htm
The code targets Office Automation - hence, the language: VBA. However,
the
logic seems simple to port to C++. I believe the relevant part is the
calls
to EnumPrinters and then the formatting of the name.
Hope the above is useful.
Regards,
Bruneau.
"Uli" <nospam (AT) nospam (DOT) de> wrote in message
news:40befa73$1 (AT) newsgroups (DOT) borland.com...
I'm working/interacting with Excel using pure OLE-interface
functionality
(like I posted already on 24.05.04)
I want to change the printer with
vExcelApp.OlePropertySet("ActivePrinter) szPrinterName);
Basically this works but there are some difficulties!
The Problem changing the active printer is, that you have to specify
exactly
the same printer-setting-string (szPrinterName) like Excel would do
this.
This means:
1. language-dependent
2. port-dependent
3. it may be, that the correct printer name varies from this shown in
the
selection-list
For example:
(1.) "Acrobat Distiller auf Ne03:" / "Acrobat Distiller on Ne03:"
(2.) "Acrobat Distiller auf Ne03:" / "HP LaserJet 5100 PCL 6 auf NE00:"
/
PostScript-Printer auf FILE:"
First I thought, that Ne## is the index of the printer in the
printer-selection-list. But this sucks, if there's installed a printer
which
uses a file for printout (like the PostScript-Printer above) - then the
index numbers don't fit the port-nr.
So, how can I retrieve the correct string for printer-setting to make it
"well formed" for excel. Otherwise Excel throws an exception and the
printer-selection won't be done.
Has anyone an idea for this or knows another method to change the
ActualPrinter which Excel uses for a current print-out (without changing
the
system's standard-printer)?
Thanks in advance,
Uli.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|