BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel-OLE: changing ActivePrinter

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
Uli
Guest





PostPosted: Thu Jun 03, 2004 10:16 am    Post subject: Excel-OLE: changing ActivePrinter Reply with 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
Jean-Marie Babet
Guest





PostPosted: Thu Jun 03, 2004 5:14 pm    Post subject: Re: Excel-OLE: changing ActivePrinter Reply with 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

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





PostPosted: Fri Jun 04, 2004 9:07 am    Post subject: Re: Excel-OLE: changing ActivePrinter Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.