PDA

View Full Version : Code doesn't work when checked Word as editor



efto
09-06-2005, 04:37 AM
This code doesn't work when checked Word as editor. When the Outlook is editor it's working fine. Any solution?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim bCancelSend As Boolean

If TypeName(Item) <> "MailItem" Then Exit Sub

'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
bCancelSend = MsgBox("This message does not have a subject." & vbNewLine & _
"Do you wish to continue sending anyway?", _
vbYesNo + vbExclamation, "No Subject") = vbNo
End If

'Cancel sending message if answered yes to the message box.
Cancel = bCancelSend
End Sub

MWE
09-06-2005, 06:22 AM
This code doesn't work when checked Word as editor. When the Outlook is editor it's working fine. Any solution?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim bCancelSend As Boolean

If TypeName(Item) <> "MailItem" Then Exit Sub

'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
bCancelSend = MsgBox("This message does not have a subject." & vbNewLine & _
"Do you wish to continue sending anyway?", _
vbYesNo + vbExclamation, "No Subject") = vbNo
End If

'Cancel sending message if answered yes to the message box.
Cancel = bCancelSend
End Sub

FINALLY someone else with this problem !!

I ran into this about a year ago.:banghead::banghead: The problem (at least for me) was a little more subtle. The ItemSend proc did not work if I were using Word as my Outlook editor AND if I were sending certain types of messages. In particular, if I created a message from scratch, it did not seem to matter what format (text, RTL or HTML) I used, the ItemSend proc did not execute. However, if I replied to a email sent to me from someone on an Exchange server who was using Word as their editor, then the ItemSend proc worked. I suspect that there is some weird combination fo flags inside Outlook that must line up (like the planets?) for this to work.

I spent a month on the MS Outlook News Community and eventually exchanged notes with Sue Mosher (one of the best Outlook experts), but she was stumped.:banghead::banghead:

MOS MASTER
09-06-2005, 11:21 AM
Hi Efto welcome to VBAX! :hi:

I'm sorry but your code works fine over here. (What version are you running?)

Hi Mark.

I remember your question as well as not finding a sollution to your problem or being able to reproduce the problem.

Efto..do you have more specifics for me? I forgot a bit about Mark's question but am I right that the Event doesn't execute? (So no question is asked)...it just doesn't run at times? :whistle:

efto
09-07-2005, 12:43 AM
I am running Outlook 2000 SR-1 (Windows XP Professional). When it's checked Word as editor for messages, nothing happens and the message is sent with blank subject. When it's unchecked Word as editor, the code works fine. If I try to send message with blank subject message box appears: "This message does not have a subject. Do you wish to continue sending anyway?" with Yes & No options.
So the question is how to make this code to work if it's chosen Word as editor for messages.

MWE
09-07-2005, 06:21 AM
Moose: I did some new testing to see if I can replicate efto's problem on several computers:


DeskTop running Win2k Pro/Sp4 (5.00.2195) with Outlook2K/SP3 (9.0.0.6627): Item_Send procedure executes when using normal embedded editor and when using Word. This is strange http://vbaexpress.com/forum/images/smilies/102.gif because ~ this combination (probably Win2K/SP3 and the same Outlook2K on another computer) DID NOT work when Word was the editor
Laptop running WinXP Pro/SP2 with Outlook2K/SR-1 (9.0.0.3721): Item_Send procedure executes when using normal embedded editor and when using Word.
desktop running WinXP Pro/SP2 with Outlook2K/SR-1 (9.0.0.3721): Item_Send procedure executes when using normal embedded editor and when using Word.
UPDATE (1505 GMT): I then did some Replies to various types of messages using the embedded editor and Word and can now duplicate the problems I had previously. It appears that if Word were used originally as the editor, then the ItemSend proc executes when I reply with Word or reply using the embedded editor. However, if Word was NOT used, then if I reply using the embedded editor, the proc executes, but if I reply using Word, the proc does not execute. This is consistent with the problems of a year ago.http://vbaexpress.com/forum/images/smilies/banghead.gifhttp://vbaexpress.com/forum/images/smilies/banghead.gif I had thought that it was people using Exchange, but, I suspect, it is messages initiated with Word (most people running on Exchange probably use Word as their email editor)

efto: do you have the problem with the proc not executing if you start a new message using Word?

MOS MASTER
09-07-2005, 09:37 AM
I am running Outlook 2000 SR-1 (Windows XP Professional). When it's checked Word as editor for messages, nothing happens and the message is sent with blank subject. When it's unchecked Word as editor, the code works fine. If I try to send message with blank subject message box appears: "This message does not have a subject. Do you wish to continue sending anyway?" with Yes & No options.
So the question is how to make this code to work if it's chosen Word as editor for messages.

Hi, :hi:

For now I have no idea what is happening. (Can't reproduce it)

We had this question before like Mark said:
http://vbaexpress.com/forum/showthread.php?t=3516

Perhaps there's something new there.

If I find something I let you know. :whistle:

MOS MASTER
09-07-2005, 09:39 AM
Hi Mark, :yes

I'll try your tests out on my machine at home that has win2k and office 2k to reproduce it.

Thanx. :whistle:

MOS MASTER
09-07-2005, 12:52 PM
Okay I was thinking...(Go figure) :rofl:

You are using the build-in Application eventhandler for send email Application_ItemSend

Well that one seams to fail for you guys...I just got the idea of building our Own Eventhandler to deal with that problem. (That get's triggerd sepparate so that might work)

Ok go to the VBE of Outlook and DoubleClick on: "ThisOutlookSession" (Classmodule)

Paste this code:
'Code in ThisOutlookSession
Option Explicit

Public WithEvents myOlApp As Outlook.Application

Private Sub Application_Quit()
'Event gets triggered when you quit Outlook
'Clean up
Set myOlApp = Nothing
End Sub

Private Sub Application_Startup()
'Event gets triggered when you start Outlook
'Initialize myOlApp
Set myOlApp = Application
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim bCancelSend As Boolean
If TypeName(Item) <> "MailItem" Then Exit Sub
'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
bCancelSend = MsgBox("This message does not have a subject." & vbNewLine & _
"Do you wish to continue sending anyway?", _
vbYesNo + vbExclamation, "No Subject") = vbNo
End If
'Cancel sending message if answered yes to the message box.
Cancel = bCancelSend
End Sub


It looks pretty much as your own event you're using but it is now a separete handler. (You could check by adding your own so now the event is fired twice)

So guys try it out and let me know! (I'll laugh my ass off if this works!!)

HTH, :whistle:

MOS MASTER
09-08-2005, 02:02 PM
WHAT??? no takers?? :mkay

Ok I'll go and eat my hat now! :boohoo :rofl:

MWE
09-08-2005, 08:21 PM
WHAT??? no takers?? :mkay

Ok I'll go and eat my hat now! :boohoo :rofl:
sorry, I did not see your post (and amazing work). I will try it and post back.

MWE
09-08-2005, 08:30 PM
Okay I was thinking...(Go figure) :rofl:

You are using the build-in Application eventhandler for send email Application_ItemSend

Well that one seams to fail for you guys...I just got the idea of building our Own Eventhandler to deal with that problem. (That get's triggerd sepparate so that might work)

Ok go to the VBE of Outlook and DoubleClick on: "ThisOutlookSession" (Classmodule)


It looks pretty much as your own event you're using but it is now a separete handler. (You could check by adding your own so now the event is fired twice)

So guys try it out and let me know! (I'll laugh my ass off if this works!!)

HTH, :whistle:
not sure what a Moose without a posterior means -- must be pretty painful. :eek: In the future please qualify your status with an appropriate acronym appended to your signature:


MWA: Moose With Ass
MWOA: Moose WithOut Ass
After all, if kpuls can bring the forum to a halt with "CMA", you should have equal time ...

efto
09-09-2005, 12:21 AM
MWE: The proc not executing if I start a new message using Word as editor and mail format HTML or Plain Text.
If it is chosen Word as editor and mail format - Microsoft Outlook Rich Text IT WORKS!

If it is chosen Outlook as editor it works with all 3 mail formats (HTML, Microsoft Outlook Rich Text or Plain Text)


MOS MASTER: Sorry, your code doesn't work here :( I pasted your code along with my own, then only your code, but still nothing...

MOS MASTER
09-10-2005, 06:15 AM
After all, if kpuls can bring the forum to a halt with "CMA", you should have equal time ...

Very true buddy!

I'll try to mention my current state of posterior in future events. :rofl:

MOS MASTER
09-10-2005, 06:17 AM
MOS MASTER: Sorry, your code doesn't work here :( I pasted your code along with my own, then only your code, but still nothing...

Sorry to here that. It was the very best I could come up with! :dunno

Like mentioned in the article by Mark I pointed him to discuss it with Sue Mosher a Outlook MVP and if she doesn't understand it then.....

Seams to be a unrecognised bug by MS and there doesn't seam to be a workarround for it....:whistle:

efto
09-12-2005, 07:53 AM
So, it looks like finding solution for this problem is very difficult.
MOS,MWE thank you very much for trying to help me.

MOS MASTER
09-12-2005, 08:42 AM
Yes this one does seam a problem to fix.....

No problem you're welcome! :yes