none
VBA Macro to sort the items in a the current folder RRS feed

  • Question

  • Hi,
    Since there are no keyboard shortcuts to sort the items by From/To/Subject/... in the current folder I was thinking of writing a macro which can do this using VBA and assign a keyboard shortcut.
    But I am not sure how to get the sort to apply on the actual view of the folder in outlook. The sort method for Items or Table is not applied on the running instance of outlook and is instead to be used within the script. Any help pointing me towards the right direction will be appreciated.
    Tuesday, February 18, 2014 8:56 AM

Answers

  • Hello nsmathew,

    You are right, the Sort method of the Items or Table class just sorts items in memory, not in the explorer window. If you want to customize the current view in Outlook window you need to use the CurrentView property of the Folder or Explorer class. It returns an instance of the View class representing the current view. Here is what MSDN states for Views:

    To obtain a View object for the view of the current Explorer, use Explorer.CurrentView instead of the CurrentView property of the current Folder object returned by Explorer.CurrentFolder.

    You must save a reference to the View object returned by CurrentView before you proceed to use it for any purpose.

    To properly reset the current view, you must do a View.Reset and then a View.Apply.

    Tuesday, February 18, 2014 12:59 PM

All replies

  • Hello nsmathew,

    You are right, the Sort method of the Items or Table class just sorts items in memory, not in the explorer window. If you want to customize the current view in Outlook window you need to use the CurrentView property of the Folder or Explorer class. It returns an instance of the View class representing the current view. Here is what MSDN states for Views:

    To obtain a View object for the view of the current Explorer, use Explorer.CurrentView instead of the CurrentView property of the current Folder object returned by Explorer.CurrentFolder.

    You must save a reference to the View object returned by CurrentView before you proceed to use it for any purpose.

    To properly reset the current view, you must do a View.Reset and then a View.Apply.

    Tuesday, February 18, 2014 12:59 PM
  • Thanks Eugene.
    Thursday, February 20, 2014 5:26 AM