Outlook macro help please

V

Victor Delta

Can anyone please tell me how to record a macro on Outlook please (I'm using
Office 2003). I was expecting the same sort of 'record new macro' facility
as exists in Word and Excel, but it doesn't seem to be there.

All I'm trying to do is create a macro which changes the active printer,
prints the current email, and then resets the active printer to the default
printer.

Without the usual macro 'wizard', so far I've only got as far as '
ActivePrinter "Printer2" '.

Can anyone help please?

TIA

V
 
K

Ken Slovak - [MVP - Outlook]

No macro recorder in Outlook, never was, never will be.

Outlook reads the default system printer on startup and the only print
method you have is to print. No arguments, no settings, just print. That's
it.
 
V

Victor Delta

Ken Slovak - said:
No macro recorder in Outlook, never was, never will be.

Outlook reads the default system printer on startup and the only print
method you have is to print. No arguments, no settings, just print. That's
it.

Thanks, Ken. So, if I understand you correctly, you're saying that the
simple task I am attempting is just not possible (using a macro anyway)? Is
that so?

V
 
K

Ken Slovak - [MVP - Outlook]

It's not possible at all in Outlook. If you want to format your printout, be
selective in what's printed or print to a specific printer or use background
printing most of us use Word and take the data we want and put it into a
Word template and then do the printing using the Word object model.
 
V

Victor Delta

Ken Slovak - said:
It's not possible at all in Outlook. If you want to format your printout,
be selective in what's printed or print to a specific printer or use
background printing most of us use Word and take the data we want and put
it into a Word template and then do the printing using the Word object
model.

Many thanks for that, although I have to say I am very surprised and
disappointed that VBA in Outlook is so limited. I gather you cannot even set
the active printer as in other Office applications.

However, I haven't given up quite yet and wondered if anyone knows if there
are any third party applications that would help? For example, there used to
be a nifty freeware programme available that enabled one to automate certain
routine tasks but I can't remember it's details. Certainly changing the
printer is not terribly complicated in terms of key strokes so I don't know
if this would be a possibility?

Incidentally the reason I am trying to do this is to use Green Print with
Outlook (only). Green Print can be downloaded from www.printgreener.com (the
'world' version is free) and it works between applications and one's printer
and enables one to easily stop blank or unimportant pages being printed. So
for Outlook it is ideal - and saves what you describe about having to copy
and paste data to Word etc for controlled printing. However, for Word etc it
just slows things down (an unnecessary extra stage in the printing process)
and so I don't want it to be the default printer.

V

PS Suppose one way round this would be set Green Print as the default
printer and then write macros for all the other Office programmes to set
their active printers to the 'real' printer? A laboriously long way round...
 
P

PaulD

This can be done by changing the default printer using vba but it takes a
little bit of code. I will do my best to explain.
First create a new module in the vba editor in outlook (VbaProject.OTM), you
can set the name to anything you would like
at the very top (just below Option Explicit if it's there) paste the
following

Public Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Sub PrintGreen()
Dim strDefault As String
Dim WshNetwork As WshNetwork
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim mySelection As Selection

Set myOlApp = Application
Set mySelection = myOlApp.ActiveExplorer.Selection
Set WshNetwork = CreateObject("WScript.Network")
strDefault = DefaultPrinter
WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
For i = mySelection.count To 1 Step -1
If mySelection.Item(i).Class = olMail Then mySelection.Item(i).PrintOut
Next i
WshNetwork.SetDefaultPrinter (strDefault) ' restore default
End Sub

Public Function DefaultPrinter() As String
Dim strReturn As String
Dim intReturn As Integer
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
DefaultPrinter = strReturn
End Function

You can now create a button and assign the PrintGreen macro to it and it
should print any emails you have selected to your specified printer. I did
test this on my computer and found there is a several second (ok like 10)
delay while printing. You may or may not have this issue. Anyway, post
back if you have any questions.
Paul D

: : > It's not possible at all in Outlook. If you want to format your
printout,
: > be selective in what's printed or print to a specific printer or use
: > background printing most of us use Word and take the data we want and
put
: > it into a Word template and then do the printing using the Word object
: > model.
:
: Many thanks for that, although I have to say I am very surprised and
: disappointed that VBA in Outlook is so limited. I gather you cannot even
set
: the active printer as in other Office applications.
:
: However, I haven't given up quite yet and wondered if anyone knows if
there
: are any third party applications that would help? For example, there used
to
: be a nifty freeware programme available that enabled one to automate
certain
: routine tasks but I can't remember it's details. Certainly changing the
: printer is not terribly complicated in terms of key strokes so I don't
know
: if this would be a possibility?
:
: Incidentally the reason I am trying to do this is to use Green Print with
: Outlook (only). Green Print can be downloaded from www.printgreener.com
(the
: 'world' version is free) and it works between applications and one's
printer
: and enables one to easily stop blank or unimportant pages being printed.
So
: for Outlook it is ideal - and saves what you describe about having to copy
: and paste data to Word etc for controlled printing. However, for Word etc
it
: just slows things down (an unnecessary extra stage in the printing
process)
: and so I don't want it to be the default printer.
:
: V
:
: PS Suppose one way round this would be set Green Print as the default
: printer and then write macros for all the other Office programmes to set
: their active printers to the 'real' printer? A laboriously long way
round...
:
 
V

Victor Delta

PaulD said:
This can be done by changing the default printer using vba but it takes a
little bit of code. I will do my best to explain.
First create a new module in the vba editor in outlook (VbaProject.OTM),
you
can set the name to anything you would like
at the very top (just below Option Explicit if it's there) paste the
following

Public Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Sub PrintGreen()
Dim strDefault As String
Dim WshNetwork As WshNetwork
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim mySelection As Selection

Set myOlApp = Application
Set mySelection = myOlApp.ActiveExplorer.Selection
Set WshNetwork = CreateObject("WScript.Network")
strDefault = DefaultPrinter
WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
For i = mySelection.count To 1 Step -1
If mySelection.Item(i).Class = olMail Then mySelection.Item(i).PrintOut
Next i
WshNetwork.SetDefaultPrinter (strDefault) ' restore default
End Sub

Public Function DefaultPrinter() As String
Dim strReturn As String
Dim intReturn As Integer
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
DefaultPrinter = strReturn
End Function

You can now create a button and assign the PrintGreen macro to it and it
should print any emails you have selected to your specified printer. I
did
test this on my computer and found there is a several second (ok like 10)
delay while printing. You may or may not have this issue. Anyway, post
back if you have any questions.
Paul D

Paul

Many thanks - that's very interesting. I'll give it a try and let you know
how I get on.

V
 
V

Victor Delta

Paul

Just a thought. In view of the delay, would it be better to write the code
so that the printer is changed when Outlook opens?

V
 
P

PaulD

Victor,
That could easily be done, the only issue I see is if you leave outlook open
all the time (like I do), then the default printer will be incorrect for
other programs until you close outlook. Maybe not an issue for you, so if
that's the case you would have to add some event code to ThisOutlookSession:

Option Explicit
Dim strDefaultPrinter As String

Private Sub Application_Startup()
Dim WshNetwork As WshNetwork
Dim strReturn As String
Dim intReturn As Integer

strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
strDefaultPrinter = strReturn 'save default printer
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter ("YOUR PRINTER NAME HERE")
Set WshNetwork = Nothing
End Sub

Private Sub Application_Quit()
Dim WshNetwork As WshNetwork

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter (strDefaultPrinter) ' restore default
Set WshNetwork = Nothing
End Sub

I would leave the Public Declare function GetProfileString in its own module
called Declarations and delete the sub PrintGreen and function
DefaultPrinter
Paul D


:> "PaulD" <nospam> wrote in message
: >>
: >> You can now create a button and assign the PrintGreen macro to it and
it
: >> should print any emails you have selected to your specified printer. I
: >> did
: >> test this on my computer and found there is a several second (ok like
10)
: >> delay while printing. You may or may not have this issue. Anyway,
post
: >> back if you have any questions.
: >> Paul D
:
: Paul
:
: Just a thought. In view of the delay, would it be better to write the code
: so that the printer is changed when Outlook opens?
:
: V
:
 
V

Victor Delta

PaulD said:
Victor,
That could easily be done, the only issue I see is if you leave outlook
open
all the time (like I do), then the default printer will be incorrect for
other programs until you close outlook. Maybe not an issue for you, so if
that's the case you would have to add some event code to
ThisOutlookSession:

Option Explicit
Dim strDefaultPrinter As String

Private Sub Application_Startup()
Dim WshNetwork As WshNetwork
Dim strReturn As String
Dim intReturn As Integer

strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
strDefaultPrinter = strReturn 'save default printer
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter ("YOUR PRINTER NAME HERE")
Set WshNetwork = Nothing
End Sub

Private Sub Application_Quit()
Dim WshNetwork As WshNetwork

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter (strDefaultPrinter) ' restore default
Set WshNetwork = Nothing
End Sub

I would leave the Public Declare function GetProfileString in its own
module
called Declarations and delete the sub PrintGreen and function
DefaultPrinter
Paul D

Thanks, good point!

V
 
V

Victor Delta

PaulD said:
This can be done by changing the default printer using vba but it takes a
little bit of code. I will do my best to explain.
First create a new module in the vba editor in outlook (VbaProject.OTM),
you
can set the name to anything you would like
at the very top (just below Option Explicit if it's there) paste the
following

Public Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Sub PrintGreen()
Dim strDefault As String
Dim WshNetwork As WshNetwork
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim mySelection As Selection

Set myOlApp = Application
Set mySelection = myOlApp.ActiveExplorer.Selection
Set WshNetwork = CreateObject("WScript.Network")
strDefault = DefaultPrinter
WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
For i = mySelection.count To 1 Step -1
If mySelection.Item(i).Class = olMail Then mySelection.Item(i).PrintOut
Next i
WshNetwork.SetDefaultPrinter (strDefault) ' restore default
End Sub

Public Function DefaultPrinter() As String
Dim strReturn As String
Dim intReturn As Integer
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
DefaultPrinter = strReturn
End Function

You can now create a button and assign the PrintGreen macro to it and it
should print any emails you have selected to your specified printer. I
did
test this on my computer and found there is a several second (ok like 10)
delay while printing. You may or may not have this issue. Anyway, post
back if you have any questions.
Paul D

Paul

I followed your instructions and tried your original code today.

However, when I tried to run it, a compile error message came up -
'WshNetwork As WshNetwork' was highlighted and the message said
'User-defined type not defined'. Any idea how to resolve this?

V
 
V

Victor Delta

Victor Delta said:
Paul

I followed your instructions and tried your original code today.

However, when I tried to run it, a compile error message came up -
'WshNetwork As WshNetwork' was highlighted and the message said
'User-defined type not defined'. Any idea how to resolve this?

V

Paul

After a bit of experimentation, I changed the line to

Dim WshNetwork As Object

and the macro now runs. However, it just seems to still send documents to
the default printer - even through I changed "ENTER YOUR PRINTER NAME HERE!"
to "GreenPrint"?

V
 
K

Ken Slovak - [MVP - Outlook]

Outlook only reads the printer to use when it starts up. You can change the
system printer as often as you want and it won't matter if you don't do it
before Outlook starts. There is no way, using the Outlook item.PrintOut()
method to select or change the printer being used.
 
P

PaulD

Ken,
Intesting comment since I tested this using Outlook 2003 and it does work.
Have you tested this yourself ? Without any code you can test this by
printing an email, then going into your printers settings, changing your
default printer then printing the email again.
Paul D

: Outlook only reads the printer to use when it starts up. You can change
the
: system printer as often as you want and it won't matter if you don't do it
: before Outlook starts. There is no way, using the Outlook item.PrintOut()
: method to select or change the printer being used.
:
: --
: Ken Slovak
: [MVP - Outlook]
: http://www.slovaktech.com
: Author: Professional Programming Outlook 2007.
: Reminder Manager, Extended Reminders, Attachment Options.
: http://www.slovaktech.com/products.htm
:
:
: : <snip>
: > After a bit of experimentation, I changed the line to
: >
: > Dim WshNetwork As Object
: >
: > and the macro now runs. However, it just seems to still send documents
to
: > the default printer - even through I changed "ENTER YOUR PRINTER NAME
: > HERE!" to "GreenPrint"?
: >
: > V
:
 
P

PaulD

Victor,
My mistake for not telling you to set the appropriate reference. Anyway, I
would assume you may not have the correct printer name being used. To
verify this set your "GreenPrint" as the default printer first, then set a
break point in the PrintGreen sub at the line
WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
Now run the code to your breakpoint and verify what text is being stored in
the strDefault string. This text is the exact text you need to used in the
"ENTER YOUR PRINTER..." area
Paul D

: : > "PaulD" <nospam> wrote in message
: > : >> This can be done by changing the default printer using vba but it takes
a
: >> little bit of code. I will do my best to explain.
: >> First create a new module in the vba editor in outlook
(VbaProject.OTM),
: >> you
: >> can set the name to anything you would like
: >> at the very top (just below Option Explicit if it's there) paste the
: >> following
: >>
: >> Public Declare Function GetProfileString Lib "kernel32" _
: >> Alias "GetProfileStringA" _
: >> (ByVal lpAppName As String, _
: >> ByVal lpKeyName As String, _
: >> ByVal lpDefault As String, _
: >> ByVal lpReturnedString As String, _
: >> ByVal nSize As Long) As Long
: >>
: >> Sub PrintGreen()
: >> Dim strDefault As String
: >> Dim WshNetwork As WshNetwork
: >> Dim i As Integer
: >> Dim myOlApp As Outlook.Application
: >> Dim mySelection As Selection
: >>
: >> Set myOlApp = Application
: >> Set mySelection = myOlApp.ActiveExplorer.Selection
: >> Set WshNetwork = CreateObject("WScript.Network")
: >> strDefault = DefaultPrinter
: >> WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
: >> For i = mySelection.count To 1 Step -1
: >> If mySelection.Item(i).Class = olMail Then
: >> mySelection.Item(i).PrintOut
: >> Next i
: >> WshNetwork.SetDefaultPrinter (strDefault) ' restore default
: >> End Sub
: >>
: >> Public Function DefaultPrinter() As String
: >> Dim strReturn As String
: >> Dim intReturn As Integer
: >> strReturn = Space(255)
: >> intReturn = GetProfileString("Windows", ByVal "device", "", _
: >> strReturn, Len(strReturn))
: >> If intReturn Then
: >> strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
: >> End If
: >> DefaultPrinter = strReturn
: >> End Function
: >>
: >> You can now create a button and assign the PrintGreen macro to it and
it
: >> should print any emails you have selected to your specified printer. I
: >> did
: >> test this on my computer and found there is a several second (ok like
10)
: >> delay while printing. You may or may not have this issue. Anyway,
post
: >> back if you have any questions.
: >> Paul D
: >
: > Paul
: >
: > I followed your instructions and tried your original code today.
: >
: > However, when I tried to run it, a compile error message came up -
: > 'WshNetwork As WshNetwork' was highlighted and the message said
: > 'User-defined type not defined'. Any idea how to resolve this?
: >
: > V
:
: Paul
:
: After a bit of experimentation, I changed the line to
:
: Dim WshNetwork As Object
:
: and the macro now runs. However, it just seems to still send documents to
: the default printer - even through I changed "ENTER YOUR PRINTER NAME
HERE!"
: to "GreenPrint"?
:
: V
:
 
K

Ken Slovak - [MVP - Outlook]

I haven't tested that in a few years, unless something changed that's the
way it always was. It's possible that MS changed things to read the current
printer when PrintOut() is called however.
 
V

Victor Delta

PaulD said:
Victor,
My mistake for not telling you to set the appropriate reference. Anyway,
I
would assume you may not have the correct printer name being used. To
verify this set your "GreenPrint" as the default printer first, then set a
break point in the PrintGreen sub at the line
WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
Now run the code to your breakpoint and verify what text is being stored
in
the strDefault string. This text is the exact text you need to used in
the
"ENTER YOUR PRINTER..." area
Paul D

Paul

Many thanks for that. However, I'm still having problems.

I followed your advice above and found that the correct printer name is
GREENPRINT so inserted this in the code which now looks like this (by the
way, was I correct about changing to 'Dim WshNetwork As Object'?):

Public Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Sub PrintGreen()
Dim strDefault As String
Dim WshNetwork As Object
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim mySelection As Selection

Set myOlApp = Application
Set mySelection = myOlApp.ActiveExplorer.Selection
Set WshNetwork = CreateObject("WScript.Network")
strDefault = DefaultPrinter
WshNetwork.SetDefaultPrinter ("GREENPRINT")
For i = mySelection.Count To 1 Step -1
If mySelection.Item(i).Class = olMail Then mySelection.Item(i).PrintOut
Next i
WshNetwork.SetDefaultPrinter (strDefault) ' restore default
End Sub

Public Function DefaultPrinter() As String
Dim strReturn As String
Dim intReturn As Integer
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
DefaultPrinter = strReturn
End Function

However, when I run this with the original default printer set, the print
goes to the default printer not Green Print! Have I made a mistake
somewhere?

Obviously it's working at your end - have you made any other changes
perhaps?

I'm glad this is possible because although I'm sure Ken is very expert in
such matters, it must be possible to change the Outlook printer otherwise
one wouldn't be able to do it manually so easily (couple of clicks) via the
print dialogue box. I just couldn't understand this before.

Thanks again for all your help...

V
 
P

PaulD

Victor,
You were correct to change 'Dim WshNetwork As Object', that should work.
Since you could follow my directions before, I would recommened you try
this: set a break point on the line
For i = mySelection.Count To 1 Step -1
in the PrintGreen sub and then run the code. You should be able to hover
over the strDefault variable to see if it was set, then open your printers
and faxes window and see if the default printer was switched. To make sure
I have the same code as you I copied the code from your post below into a
new module and ran it to make sure it worked. I got an error saying it
couldn't find the printer "GREENPRINT" which is good since I don't have that
printer. I changed it to a network printer I do have (CutePDF) and it
worked. Investigae some more and post back with your results
Paul D

: "PaulD" <nospam> wrote in message
: : > Victor,
: > My mistake for not telling you to set the appropriate reference.
Anyway,
: > I
: > would assume you may not have the correct printer name being used. To
: > verify this set your "GreenPrint" as the default printer first, then set
a
: > break point in the PrintGreen sub at the line
: > WshNetwork.SetDefaultPrinter ("ENTER YOUR PRINTER NAME HERE!")
: > Now run the code to your breakpoint and verify what text is being stored
: > in
: > the strDefault string. This text is the exact text you need to used in
: > the
: > "ENTER YOUR PRINTER..." area
: > Paul D
:
: Paul
:
: Many thanks for that. However, I'm still having problems.
:
: I followed your advice above and found that the correct printer name is
: GREENPRINT so inserted this in the code which now looks like this (by the
: way, was I correct about changing to 'Dim WshNetwork As Object'?):
:
: Public Declare Function GetProfileString Lib "kernel32" _
: Alias "GetProfileStringA" _
: (ByVal lpAppName As String, _
: ByVal lpKeyName As String, _
: ByVal lpDefault As String, _
: ByVal lpReturnedString As String, _
: ByVal nSize As Long) As Long
:
: Sub PrintGreen()
: Dim strDefault As String
: Dim WshNetwork As Object
: Dim i As Integer
: Dim myOlApp As Outlook.Application
: Dim mySelection As Selection
:
: Set myOlApp = Application
: Set mySelection = myOlApp.ActiveExplorer.Selection
: Set WshNetwork = CreateObject("WScript.Network")
: strDefault = DefaultPrinter
: WshNetwork.SetDefaultPrinter ("GREENPRINT")
: For i = mySelection.Count To 1 Step -1
: If mySelection.Item(i).Class = olMail Then mySelection.Item(i).PrintOut
: Next i
: WshNetwork.SetDefaultPrinter (strDefault) ' restore default
: End Sub
:
: Public Function DefaultPrinter() As String
: Dim strReturn As String
: Dim intReturn As Integer
: strReturn = Space(255)
: intReturn = GetProfileString("Windows", ByVal "device", "", _
: strReturn, Len(strReturn))
: If intReturn Then
: strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
: End If
: DefaultPrinter = strReturn
: End Function
:
: However, when I run this with the original default printer set, the print
: goes to the default printer not Green Print! Have I made a mistake
: somewhere?
:
: Obviously it's working at your end - have you made any other changes
: perhaps?
:
: I'm glad this is possible because although I'm sure Ken is very expert in
: such matters, it must be possible to change the Outlook printer otherwise
: one wouldn't be able to do it manually so easily (couple of clicks) via
the
: print dialogue box. I just couldn't understand this before.
:
: Thanks again for all your help...
:
: V
:
 
V

Victor Delta

PaulD said:
Victor,
You were correct to change 'Dim WshNetwork As Object', that should work.
Since you could follow my directions before, I would recommened you try
this: set a break point on the line
For i = mySelection.Count To 1 Step -1
in the PrintGreen sub and then run the code. You should be able to hover
over the strDefault variable to see if it was set, then open your printers
and faxes window and see if the default printer was switched. To make
sure
I have the same code as you I copied the code from your post below into a
new module and ran it to make sure it worked. I got an error saying it
couldn't find the printer "GREENPRINT" which is good since I don't have
that
printer. I changed it to a network printer I do have (CutePDF) and it
worked. Investigae some more and post back with your results
Paul D

Paul

Thanks. This is most odd. Followed your instructions and sure enough, using
the break point, the default printer does change to Green Print and then
changes back. However, the print out still seems to go through to the wrong
printer, although on a couple of occasions when using Step into (F8) I got
it to go to Green Print. I've been trying again and for the last 10 minutes
it will only go to the wrong printer!

I'll do some more experimentation but not quite sure why it should be so
inconsistent! Any ideas? We're so nearly there...

V
 
V

Victor Delta

Victor Delta said:
Paul

Thanks. This is most odd. Followed your instructions and sure enough,
using
the break point, the default printer does change to Green Print and then
changes back. However, the print out still seems to go through to the
wrong
printer, although on a couple of occasions when using Step into (F8) I got
it to go to Green Print. I've been trying again and for the last 10
minutes
it will only go to the wrong printer!

I'll do some more experimentation but not quite sure why it should be so
inconsistent! Any ideas? We're so nearly there...

Have done some more experimentation and believe I have now found the
problem - and it's very interesting.

To aid clarity lets call the two printers Printer A (normal default) and
Printer Green. Once Outlook is open, if you change the default printer
(either manually or via your macro with the break point on the "For i = ..."
line) if you hover over the Print button at the top of any email, you will
see the name of the new printer (in my case Printer Green). This looks very
promising...

However, there's a big gotcha! If you now open the Outlook Print dialogue
box (Ctrl +P), although you will see the little black tick against the name
of the new default printer, the original printer (Printer A) is actually
still selected (highlighted in blue). So if you now print, either by
clicking the button or running the second part of your code, the email goes
to the original printer. I guess this is what Ken was telling us all along!

If only there were a way to 'refresh' the printer selection to the new
default printer it would work but, so far, I haven't thought of one. Any
ideas?

The only surprise now is that you've managed to make it work at your end.
I've been using Windows XP with Outlook XP/2002 and, on another machine,
Outlook 2003. Same as you?

V
 

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