Outlook 2019 Display the output of a seach in a new Window

Status
Not open for further replies.

Witzker

Senior Member
OS Version(s)
  1. iOS
Outlook version
Outlook 2019 32-bit
Email Account
Exchange Server 2007
How can the result of e.g this search be displayes in a new window in a list with name and Email?
Code:
Sub CopyContacts()
  
   Dim ContactsFolder As Outlook.Folder
   Dim DestFolder As Outlook.Folder
   Dim ContactItems As Outlook.Items
   Dim ResItems As Outlook.Items
   Dim sFilter, strCategory As String
   Dim iNumRestricted As Integer
   Dim Item As ContactItem, CopiedItem As ContactItem

' Use the default folder
Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)

' Use the selected folder
'Set ContactsFolder = Application.ActiveExplorer.CurrentFolder

' copy to subfolder
Set DestFolder = ContactsFolder.Folders("Copies")

   ' Get all of the items in the folder
   Set ContactItems = ContactsFolder.Items
 
   'create the Restrict filter
strCategory = InputBox("Enter the category")

   sFilter = "[Categories] = " & strCategory
   ' Apply the filter to the collection
   Set ResItems = ContactItems.Restrict(sFilter)
   iNumRestricted = 0
   'Loop through the items in the collection.
   For Each Item In ResItems
      iNumRestricted = iNumRestricted + 1

I cannot find the way to schow the result in a list where I can then click the contact to open it
Hope for Suggestions
THX
 
From

These will open a new window and turn off some of the panes - if I recall correct, the new todobar can't be turned off - that's why I have it commented out. Put it at the end of the macro.

Without testing it, you would replace olkFilter with sFilter from your code -

Code:
    Call olkExplorer.Search(olkFilter, olSearchScopeAllOutlookItems)
    Call olkExplorer.Display
' hide the navigation bar & preview pane
    olkExplorer.ShowPane olFolderList, False
    olkExplorer.ShowPane olOutlookBar, False
    olkExplorer.ShowPane olPreview, False
    olkExplorer.ShowPane olNavigationPane, False
    'olkExplorer.ShowPane olToDoBar, False
 
It looks like it needs a lot more tweaking than just adding that -to the code. :(
It was opening a new window but finding mail.

For anyone who finds this this - the original macro is from this thread -

This is finding one contact.... but opens in a new window.
Code:
Sub CopyContacts()
  
   Dim ContactsFolder As Outlook.folder
   Dim DestFolder As Outlook.folder
   Dim ContactItems As Outlook.Items
   Dim ResItems As Outlook.Items
   Dim sFilter, strCategory As String
   Dim iNumRestricted As Integer
   Dim Item As ContactItem, CopiedItem As ContactItem

' Use the default folder
'Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)

Dim olkExplorer As Outlook.Explorer
Set olkExplorer = Application.Explorers.Add(Application.Session.GetDefaultFolder(olFolderContacts), olFolderDisplayNormal)

 '  Set ContactItems = ContactsFolder.Items
 
   'create the Restrict filter
strCategory = InputBox("Enter the category")

   sFilter = "[Categories] = " & strCategory
  
  
 Call olkExplorer.Search(sFilter, olSearchScopeSubfolders)
    Call olkExplorer.Display
' hide the navigation bar & preview pane
    olkExplorer.ShowPane olFolderList, False
    olkExplorer.ShowPane olOutlookBar, False
    olkExplorer.ShowPane olPreview, False
    olkExplorer.ShowPane olNavigationPane, False
    'olkExplorer.ShowPane olToDoBar, False
    

   Set Item = Nothing
   Set CopiedItem = Nothing
   Set ResItems = Nothing
   Set ContactItems = Nothing
   Set ContactsFolder = Nothing
 
End Sub
 
Code:
Sub FindContacts()
  
Dim olkExplorer As Outlook.Explorer
Dim sFilter, strCategory As String

Set olkExplorer = Application.Explorers.Add(Application.Session.GetDefaultFolder(olFolderContacts), olFolderDisplayNormal)
  
   'create the Restrict filter
strCategory = InputBox("Enter the category")
' category:="keyword"
sFilter = "Categories:=""" & strCategory & """"
  
 Call olkExplorer.Search(sFilter, olSearchScopeCurrentFolder)
    Call olkExplorer.Display
' hide the navigation bar & preview pane
    olkExplorer.ShowPane olFolderList, False
    olkExplorer.ShowPane olOutlookBar, False
    olkExplorer.ShowPane olPreview, False
   ' olkExplorer.ShowPane olNavigationPane, False
    'olkExplorer.ShowPane olToDoBar, False
    
   Set olkExplorer = Nothing
 
End Sub

All of the panes are turned off. If the nav pane is turned off, it is turned off when you restart Outlook - at least it is for me.

1674783389973.png
 
THX I will check
 
Worx great THX
the only thing to consider is to use the German field name to work in German version of Outlook
sFilter = "Categories:=""" & strCategory & """"
is
sFilter = "Kategorie:=""" & strCategory & """"

That make Things more difficult
is there a list somewhere with English and German field names?

Categories = Kategorie
and so on
 
Hi again
I now want to open the search window with a new defined View called "XSearch" that better reflects the necessary fields to open the need contact.

But without losing the current view of the contact folder.
When I close the search window.
Can you pls help with the new code?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 5
T How to find or display the sub-folder name for an Archive Search Using Outlook 10
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
K Outlook 365 After migrating to Outlook 365, some contacts display in emails with prefixes Using Outlook 0
K Daily Task List Minimized Cannot Display Using Outlook 5
J images on note field display fraction of size Using Outlook 5
J Outlook 2016 Can't display some embedded HTML images in Outlook 2016 Using Outlook 2
O After filtering, how to display all events on that day? Using Outlook 4
M All fonts in Outlook emails display with exaggerated character spacing Using Outlook 4
G Schedule recurring email and attachments display Outlook VBA and Custom Forms 3
O Tasks - how to display "snoozed" tasks and snooze-times? Using Outlook 7
P Task display now leaves little room for notes Using Outlook 10
R Capture Sender's Display name and Address Outlook VBA and Custom Forms 3
Travis Lloyd Messages Won't Display In Outlook 2019 Home & Business Using Outlook 0
A Prepending Email Addrs with "Display Name <email>" Has Stopped Working Using Outlook 0
M In Outlook Calendar remove the buttons: 'Today' and '<' (Back a day) and '>' (Forward a day) that are below the Ribbon and above the calendar display. Using Outlook 0
C Why won't Title display in message list? Using Outlook 1
R Auto display of new email does not work on non-default account Outlook VBA and Custom Forms 0
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
T Column to display which email alias a message was sent to Outlook VBA and Custom Forms 6
M Daily Task List Minimized Cannot Display Using Outlook 2
C Outlook Mobile app email order randomized and display names stripped Using Outlook 6
N Contact display as Using Outlook 2
J Reminders Display then Disappear Using Outlook 13
O How to display senders email address (column) Using Outlook 1
S Display PF contact folder items to select contact to link to appointment Outlook VBA and Custom Forms 1
I How to display sender's name instead of email address in outlook 2013 message Using Outlook 5
O How to display number of items per .pst file Using Outlook 7
J Outlook 2016 message content does not display - outlook.com; exchange Using Outlook.com accounts in Outlook 9
O Display more months in 'Tasks' Using Outlook 3
soadfan Outlook rules look up display name only Using Outlook 4
C Display Sender As Contact Outlook VBA and Custom Forms 4
O How to display folder icons? Using Outlook 2
Treebys Array out of bounds .display 2016 Outlook VBA and Custom Forms 3
copperberry How to display incomplete tasks due on or before 7 days from now Using Outlook 0
T outlook 2010 mail item count doesnt match display Outlook VBA and Custom Forms 3
Diane Poremsky Category Color doesn't Display in Inbox Using Outlook 0
P How to make outlook display alert appear on top of other windows whenever a new email is received? Outlook VBA and Custom Forms 1
T Outlook 2016 Calendar multiday event display Using Outlook 4
Diane Poremsky Display the Created Date field of any Outlook item Using Outlook 0
Diane Poremsky Replace Display Names with Email Addresses Using Outlook 0
Diane Poremsky Search for All Messages from Contact and Display in New Window Using Outlook 0
K Display sub-folders in body of outlook Using Outlook 1
O How to display multi-line task in To-Do List - Outlook 2010 Using Outlook 1
Diane Poremsky Display the Recipient Email Address in the Sent Items Folder Using Outlook 0
Diane Poremsky Excel Files Won't Display in Reading Pane Using Outlook 1
D Display of Open Folders Using Outlook 0
Fozzie Bear Change the Display Name recipients see for Exchange account Exchange Server Administration 0
Diane Poremsky Pictures don't display in Outlook messages Using Outlook 4
M Outlook VBA Macro that could retrieve/display the (From, Subject, Date Received) Outlook VBA and Custom Forms 2

Similar threads

Back
Top