Changing the active printer via VBA macro

M

Markus Zänglein

Hello NG,

sorry for my recent posting in german :)

By using VBA I would like to print mails onto a specific printer device, eg.
PDF Writer, which is not the system default.

Outlook normally only prints on the default windows printer when using the
VBA printOut method.
So I already have a solution, that changes the default printer, prints out
the mail item and sets the printer back to the original.

This seemed to work but now I encountered the problem, that Outlook doesn't
react on changing the default printer any more as soon as the user has
selected a printer from the print dialog manually.
Instead, this printer selection is preserved until Outlook gets a restart.

Are there really no means to specify an active printer for Outlook ?
Word on the contrary has the Application.ActivePrinter property, which
apparently is not available in Outlook.

I would appreciate any little suggestion, since the MS Support also has no
real solution at hand. :)

thx

Markus Zänglein
 
S

Sue Mosher [MVP-Outlook]

Yes, that's the case, AFAIK. Another reason why a lot of robust Outlook
printing is done through Word.
 
M

Markus Zänglein

So, thats nice to hear.

but how shall I manage printing mails through Word?

Create a new Word instance via OLE,
passing the Mail item via clipboard or s.th. else (?)
doing the formatting (mail header, etc) and printing

When Word is used as default editor for Outlook, it is then possible to
re-use this instance?

thanks a lot

MZ
 
S

Sue Mosher [MVP-Outlook]

The details depend on the specific application. All you've mentioned is the
printing issue, not what you're trying to print. Automating Word templates
to print custom Outlook forms, for example, is long established practice.
See http://www.outlookcode.com/d/customprint.htm#word

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Markus Zänglein

Hello Sue,

that input helped me a little, thanks.

I simply like to print out a formatted mail exactly as Outlook would do it
I only wonder, how copying the message body to Word may work with formatted
HTML mails.

Simiply pasting the content of either property "Body" or "HTMLBody" does not
lead to an appropriate formatted HTML mail.
How can this be achieved?

thx

MZ
 
S

Sue Mosher [MVP-Outlook]

One approach would be to save the item as an HTML file, open it in word,
then print.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jonathan West

Hi Markus

The Default printer can be changed with purely VB code. Karl Peterson has
done a very comprehensive sample project for learning almost all there is to
know about printers here http://vb.mvps.org/samples/project.asp?id=PrnInfo.

One of thie things that project allows is to set any particular printer as
the system default printer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top