Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    862
    Thanks
    0
    Thanked 10 Times in 9 Posts

    Clearing Outlook selection

    I'm using Outlook 2010 and running VBA code which operates on the selected items in the Contacts folder.

    Code:
    For Each c In Outlook.ActiveExplorer.Selection
    ' do stuff
    Next
    When I have finished, I'd like to clear the selection, but I'm unable to find a way to do that. I found a post from Microsoft saying that it's not permitted because it's not safe/considerate for the user. Then I found something about a RemoveFromSelection method, but I don't see how to use that.

    Is it possible to clear the selected items in the Contacts (Active) Explorer once I'm finished?

    Thanks.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,939
    Thanks
    0
    Thanked 94 Times in 90 Posts
    Based on the Help files, I would guess:
    Code:
    For Each c In Outlook.ActiveExplorer.Selection
    ' do stuff
    Outlook.ActiveExplorer.RemoveFromSelection c
    Next
    I haven't tested so I don't know if it works or if it would require you to loop backwards through the selection rather than using For Each.
    Regards,
    Rory
    Microsoft MVP - Excel.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    862
    Thanks
    0
    Thanked 10 Times in 9 Posts
    Thank you very much. This works perfectly. I used your line of code as you have it, before Next. No need to loop backward or use a separate For construct.
    Thanks again.
    Richard

Posting Permissions

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