![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hello
In Outlook I can use the Find Items feature to find a contact. Eg I can look for 01222 & 456789 How can I do the same using VB? Angus |
Ads |
#2
|
|||
|
|||
![]()
You can use the Restrict method. Here's an example built from the one in
the Help file: Public Sub ContactPhoneNumber() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myContacts As Outlook.Items Dim myItems As Outlook.Items Dim myItem As Object Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms Set myItems = myContacts.Restrict("[BusinessTelephoneNumber] = '+1 (555) 555-1234'") For Each myItem In myItems If (myItem.Class = olContact) Then Debug.Print myItem.FullName End If Next End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Angus Comber" wrote: Hello In Outlook I can use the Find Items feature to find a contact. Eg I can look for 01222 & 456789 How can I do the same using VB? Angus |
#3
|
|||
|
|||
![]()
Thanks that's really helpful. However, the problem is most people enter a
telephone number with spaces. In UK a London telephone number might be 020 8888 9999 I get from a phone system 022088889999 Any ideas on how I can do a generic search which eg ignores spaces. Or ideally where I can ignore spaces, brackets, hyphens? Angus "Eric Legault [MVP - Outlook]" wrote in message ... You can use the Restrict method. Here's an example built from the one in the Help file: Public Sub ContactPhoneNumber() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myContacts As Outlook.Items Dim myItems As Outlook.Items Dim myItem As Object Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms Set myItems = myContacts.Restrict("[BusinessTelephoneNumber] = '+1 (555) 555-1234'") For Each myItem In myItems If (myItem.Class = olContact) Then Debug.Print myItem.FullName End If Next End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Angus Comber" wrote: Hello In Outlook I can use the Find Items feature to find a contact. Eg I can look for 01222 & 456789 How can I do the same using VB? Angus |
#4
|
|||
|
|||
![]()
You can't use wildcards in the search, so you'll have to perform multiple
searches for each variation of known phone number formats. A pain, I know. -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Angus Comber" wrote: Thanks that's really helpful. However, the problem is most people enter a telephone number with spaces. In UK a London telephone number might be 020 8888 9999 I get from a phone system 022088889999 Any ideas on how I can do a generic search which eg ignores spaces. Or ideally where I can ignore spaces, brackets, hyphens? Angus "Eric Legault [MVP - Outlook]" wrote in message ... You can use the Restrict method. Here's an example built from the one in the Help file: Public Sub ContactPhoneNumber() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myContacts As Outlook.Items Dim myItems As Outlook.Items Dim myItem As Object Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms Set myItems = myContacts.Restrict("[BusinessTelephoneNumber] = '+1 (555) 555-1234'") For Each myItem In myItems If (myItem.Class = olContact) Then Debug.Print myItem.FullName End If Next End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Angus Comber" wrote: Hello In Outlook I can use the Find Items feature to find a contact. Eg I can look for 01222 & 456789 How can I do the same using VB? Angus |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Annoying telephone number formatiing | Alphonse | Outlook - Installation | 4 | April 1st 06 06:24 AM |
Can I extend the number of names in the find a contact section? | JB's Fitness | Outlook - Using Contacts | 0 | March 30th 06 03:11 AM |
Outlook should let me configure telephone number formatting. | KC | Outlook - Using Contacts | 3 | February 2nd 06 04:35 PM |
show primary telephone number first? | Brian Tillman | Outlook - Using Contacts | 0 | January 11th 06 02:36 PM |
show primary telephone number first? | MarioFromBelgium | Outlook - Using Contacts | 0 | January 11th 06 01:18 PM |