Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / General MS Outlook Questions / March 2008

Tip: Looking for answers? Try searching our database.

Prompt to Print on Send

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stampie - 10 Mar 2008 17:57 GMT
A user operates a Windows XP, Office 2003 computer.

They have asked if it is possible to have a prompt to print upon sending an
email. I've never heard anything like this that sounds possible, but I can't
rule it out completely. Any ideas?

Please point me in the right direction if I'm in the wrong newsgroup.

Thanks.
Michael Bauer [MVP - Outlook] - 11 Mar 2008 07:17 GMT
That could be done with a few lines of VBA code. This sample prints received
emails and can easily be adpated:
http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

Replace:

Private Sub Items_ItemAdd(ByVal Item As Object)

by (in one row):

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

And replace:

If Mail.UnRead Then

by:

if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:

> A user operates a Windows XP, Office 2003 computer.
>
[quoted text clipped - 5 lines]
>
> Thanks.
Stampie - 11 Mar 2008 10:53 GMT
Where does the *.OTM file need to be in order for it to work?

I've tried just saving the script then restarting Outlook and sending a test
without success.

Never known how to use VB so can you explain in simple terms please?

Thanks.

> That could be done with a few lines of VBA code. This sample prints received
> emails and can easily be adpated:
[quoted text clipped - 27 lines]
> >
> > Thanks.
Michael Bauer [MVP - Outlook] - 11 Mar 2008 11:59 GMT
The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:

> Where does the *.OTM file need to be in order for it to work?
>
[quoted text clipped - 7 lines]
>> That could be done with a few lines of VBA code. This sample prints received
>> emails and can easily be adpated:

http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

>> Replace:
>>
[quoted text clipped - 11 lines]
>>
>>  if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>> Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:
>>
[quoted text clipped - 9 lines]
>>>
>>> Thanks.
Stampie - 11 Mar 2008 12:47 GMT
Thats great! It worked!

Just a couple of problems though, after clicking on send, it appears as
though Outlook hangs, but the print prompt window is sitting behind the email
I tried sending. I can minimize the message to get to the windowbut i'd
prefer if it could be brought to the front. Can it be edited to do that?

Also after the email printed, instead of having all the headings at the top
of the page (To, Cc, Bcc, Subject, etc) they were replaced with the following
lines of text...

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;} {\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\fi-1800\li1800\tx1800\cf1\b\f0\fs20
<sendername>\par To:tab\b0 <recipientname>\par \b Subject:\tab\b0
<subjectname>\par }

A colleague performed the exact same steps without any problems, although he
was using Office 2007, I on the other hand, have Office 2003 SP3.

Is it another bug in SP3 that may be causing this or have I got the wrong
code for Office 2003?

Thanks for the fix though!


> The file is being created and saved automatically by Outlook; you can find
> the file then in:
[quoted text clipped - 58 lines]
> >>>
> >>> Thanks.
Michael Bauer [MVP - Outlook] - 12 Mar 2008 07:03 GMT
1#: That happens if you use Word as email editor. Easiest approach is indeed
to minimize the Inspector. You can do that by code by calling
Item.GetInspector.WindowState=vbMinimized

#2: I don't know the reason for that. Do you sent your emails RTF formatted?

You might test if this helps:

If not Item.GetInspector.Wordeditor is Nothing Then
 Item.GetInspector.WordEditor.PrintOut
Else
 Item.PrintOut
Endif

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 04:47:02 -0700 schrieb Stampie:

> Thats great! It worked!
>
[quoted text clipped - 35 lines]
>>
>> Edit the code as suggested, click Save, and restart Outlook.

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>> Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:
>>
[quoted text clipped - 11 lines]
>> received
>>>> emails and can easily be adpated:

http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

>>>> Replace:
>>>>
[quoted text clipped - 12 lines]
>>>>
>>>>  if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>>>> Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:
>>>>
[quoted text clipped - 9 lines]
>>>>>
>>>>> Thanks.
Stampie - 12 Mar 2008 10:06 GMT
Do I just add the codes below onto the bottom of the code you gave me before
or do I create a new one?

> 1#: That happens if you use Word as email editor. Easiest approach is indeed
> to minimize the Inspector. You can do that by code by calling
[quoted text clipped - 109 lines]
> >>>>>
> >>>>> Thanks.
Michael Bauer [MVP - Outlook] - 12 Mar 2008 22:32 GMT
Replace the existing ...Printout line by the new lines, please.

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Wed, 12 Mar 2008 02:06:02 -0700 schrieb Stampie:

> Do I just add the codes below onto the bottom of the code you gave me before
> or do I create a new one?
[quoted text clipped - 12 lines]
>>   Item.PrintOut
>> Endif

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>> Am Tue, 11 Mar 2008 04:47:02 -0700 schrieb Stampie:
>>
[quoted text clipped - 43 lines]
>>>>
>>>> Edit the code as suggested, click Save, and restart Outlook.

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>>>> Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:
>>>>
[quoted text clipped - 11 lines]
>>>> received
>>>>>> emails and can easily be adpated:

http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

>>>>>> Replace:
>>>>>>
[quoted text clipped - 12 lines]
>>>>>>
>>>>>>  if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>>>>>> Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:
>>>>>>
[quoted text clipped - 10 lines]
>>>>>>>
>>>>>>> Thanks.
Stampie - 13 Mar 2008 11:17 GMT
Sorry i'm really not very good at this at all :(

Below is the currently edited code (without the new lines in) can you show
me where to place he new lines as i've tried the lines Mail.PrintOut and
PrintNewItem Item without success.

_____________________________________________
Private WithEvents Items As Outlook.Items
_____________________________________________
Private Sub Application_Startup()
 Dim Ns As Outlook.NameSpace

 Set Ns = Application.GetNamespace("MAPI")
 Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
_____________________________________________
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 If TypeOf Item Is Outlook.MailItem Then
   PrintNewItem Item
 End If
End Sub
_____________________________________________
Private Sub PrintNewItem(Mail As Outlook.MailItem)
 On Error Resume Next

 If MsgBox("Print?", vbYesNo Or vbQuestion) = vbYes Then
   Mail.PrintOut
 End If
End Sub
____________________________________________


> Replace the existing ...Printout line by the new lines, please.
Michael Bauer [MVP - Outlook] - 13 Mar 2008 11:49 GMT
Sure, replace this
 
 >     Mail.PrintOut

by this:

If not Mail.GetInspector.Wordeditor is Nothing Then
 Mail.GetInspector.WordEditor.PrintOut
Else
 Mail.PrintOut
Endif

(There was a typo, it doesn't read 'item' but 'mail').

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Thu, 13 Mar 2008 03:17:01 -0700 schrieb Stampie:

> Sorry i'm really not very good at this at all :(
>
[quoted text clipped - 29 lines]
>  
>> Replace the existing ...Printout line by the new lines, please.

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Stampie - 13 Mar 2008 12:15 GMT
So the full code should look like this...?

_____________________________________________
Private WithEvents Items As Outlook.Items
_____________________________________________
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
_____________________________________________
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
_____________________________________________
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next

If MsgBox("Print?", vbYesNo Or vbQuestion) = vbYes Then
If not Mail.GetInspector.Wordeditor is Nothing Then
Mail.GetInspector.WordEditor.PrintOut
Else
Mail.PrintOut
End if
End If
End Sub
____________________________________________

Using the above code, the lines of random text has disappeared from the
printed email, the To, Cc, Subject, etc fields are missing and the print
prompt still hides behind the email.

Are there any other options or should I admit defeat and install Office 2007?

> Sure, replace this
>  
[quoted text clipped - 45 lines]
> >>
> <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Michael Bauer [MVP - Outlook] - 13 Mar 2008 15:50 GMT
As I told you that was just a test if the weird RTF lines disappear; for
getting the prompt on top it's still the easiest to minimize the email
editor.

Signature

Best regards
Michael Bauer - MVP Outlook
 Use Outlook Categories? This is Your Tool:
 <http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Thu, 13 Mar 2008 04:15:01 -0700 schrieb Stampie:

> So the full code should look like this...?
>
[quoted text clipped - 46 lines]
>>
>> (There was a typo, it doesn't read 'item' but 'mail').

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

>> Am Thu, 13 Mar 2008 03:17:01 -0700 schrieb Stampie:
>>
[quoted text clipped - 31 lines]
>>>  
>>>> Replace the existing ...Printout line by the new lines, please.

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.