none
Explorer.SelectionChange event is fired twice RRS feed

  • Question

  • I have the following simple code in ThisOutlookSession module:

    Private WithEvents expl As Outlook.Explorer
    
    Private Sub Application_Startup()
        Set expl = Application.ActiveExplorer()
    End Sub
    
    Private Sub expl_SelectionChange()
        Debug.Print "Selection changed"
    End Sub

    I ran it in Outlook 2007 and Outlook 2013. In Outlook 2007 the event is fired once, but in Outlook 2013 it fires twice (I just select emails). Why?


    There is no knowledge that is not power.

    Saturday, July 19, 2014 4:35 PM

Answers

  • I have reproduced the issue on my PC with Outlook 2013 installed.

    After I turned off the Reading pane the SelectionChange event is fired only once. It looks like the issue is caused by the Reading pane enabled.

    Sunday, July 20, 2014 8:05 AM

All replies

  • Hello Johny,

    See Why does Explorer.SelectionChange get triggered twice? and Explorer.SelectionChange event triggered multiple times. Do you have any other add-ins installed for Outlook?

    As a workaround, you may save the EntryId values of selected items and check them next time the event is fired. If you get the same items, just ignore the event.


    Saturday, July 19, 2014 4:59 PM
  • Yes, I have already read those posts before writing here. I have only "Microsoft Exchange Add-In" (in Outlook 2007 there'are four add-ins installed by default). But even after disabling it the event is still fired twice. Those two posts don't explain the cause of such behavior - there's just remedy. And yes, I agree that it could be because of some add-in (I actually had alike problem in Word - one add-in didn't let my macro to save document, and after disabling it [thanks to google] all went fine). And no - the problem is not in add-in, as I'm assured.

    So, is it some killing-feature that I gotta pollute my code with unnecessary creating variable, storing an ID there and comparing with selected mail's ID? I even don't say that I have to explain another developer (who will revise my code) that "well, this is cool - two events for sure!". Heh, this is silly...


    There is no knowledge that is not power.


    • Edited by JohnyL Saturday, July 19, 2014 7:01 PM
    Saturday, July 19, 2014 6:57 PM
  • Do you use the cached Exchange mode in Outlook? Did you try to switch it on/off and see whether it helps?
    Saturday, July 19, 2014 7:58 PM
  • Well, according to this page, "Outlook 2013 Cached Exchange Mode works only with Exchange Server 2007 or later email accounts". I use IMAP email account, and it means I don't have this feature.

    There is no knowledge that is not power.

    Saturday, July 19, 2014 8:39 PM
  • Did you have a chance to test the event against a regular pop3/SMTP profile? Is it fired twice? The Outlook object model contains a lot of known issues that remain untouched for many years. For example, the ItemAdd event is not fired at all if more than 16 items are added simultaneously. So, I am not surprised.
    Saturday, July 19, 2014 9:56 PM
  • I tried POP3/SMTP - the event is raised twice again. If there's issue, then this issue was not in Outlook 2007. I guess, there must be some explanation to this behavior.

    There is no knowledge that is not power.

    Sunday, July 20, 2014 7:20 AM
  • I have reproduced the issue on my PC with Outlook 2013 installed.

    After I turned off the Reading pane the SelectionChange event is fired only once. It looks like the issue is caused by the Reading pane enabled.

    Sunday, July 20, 2014 8:05 AM
  • Yes! I confirm that disabling Reading pane solves the problem but... in Outlook 2007 the event raises only once WITH Reading pane!

    There is no knowledge that is not power.


    • Edited by JohnyL Sunday, July 20, 2014 10:26 AM
    Sunday, July 20, 2014 9:44 AM
  • Try to open a support case. You will not be charged if there is a real bug.
    Sunday, July 20, 2014 9:58 AM
  • Can you, please, tell where namely I should open support case? :)

    There is no knowledge that is not power.

    Sunday, July 20, 2014 10:27 AM
  • Sunday, July 20, 2014 10:37 AM