Consulting

Results 1 to 16 of 16

Thread: Code doesn't work when checked Word as editor

  1. #1
    VBAX Regular efto's Avatar
    Joined
    Aug 2005
    Posts
    23
    Location

    Code doesn't work when checked Word as editor

    This code doesn't work when checked Word as editor. When the Outlook is editor it's working fine. Any solution?
    [VBA] 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
    [/VBA]

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by efto
    This code doesn't work when checked Word as editor. When the Outlook is editor it's working fine. Any solution?
    [VBA] 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
    [/VBA]
    FINALLY someone else with this problem !!

    I ran into this about a year ago. 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.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Efto welcome to VBAX!

    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?
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  4. #4
    VBAX Regular efto's Avatar
    Joined
    Aug 2005
    Posts
    23
    Location
    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.

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Moose: I did some new testing to see if I can replicate efto's problem on several computers:

    1. 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 because ~ this combination (probably Win2K/SP3 and the same Outlook2K on another computer) DID NOT work when Word was the editor
    2. 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.
    3. 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. 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?
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by efto
    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,

    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.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Mark,

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

    Thanx.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Okay I was thinking...(Go figure)

    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:[vba]
    '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
    [/vba]

    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,
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  9. #9
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    WHAT??? no takers??

    Ok I'll go and eat my hat now!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  10. #10
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by MOS MASTER
    WHAT??? no takers??

    Ok I'll go and eat my hat now!
    sorry, I did not see your post (and amazing work). I will try it and post back.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  11. #11
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by MOS MASTER
    Okay I was thinking...(Go figure)

    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,
    not sure what a Moose without a posterior means -- must be pretty painful. In the future please qualify your status with an appropriate acronym appended to your signature:

    1. MWA: Moose With Ass
    2. MWOA: Moose WithOut Ass
    After all, if kpuls can bring the forum to a halt with "CMA", you should have equal time ...
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  12. #12
    VBAX Regular efto's Avatar
    Joined
    Aug 2005
    Posts
    23
    Location
    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...

  13. #13
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by MWE
    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.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  14. #14
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by efto
    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!

    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....
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  15. #15
    VBAX Regular efto's Avatar
    Joined
    Aug 2005
    Posts
    23
    Location
    So, it looks like finding solution for this problem is very difficult.
    MOS,MWE thank you very much for trying to help me.

  16. #16
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Yes this one does seam a problem to fix.....

    No problem you're welcome!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •