im getting a type mismatch error

Status
Not open for further replies.

cale may

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Hello,

I want to filter my inbox by searching for a single persons name.

I have done my best to follow the instructions on getting this vba code to run:

Sub SearchByAddress()
Dim myOlApp As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim strFilter As String
Dim oContact As Outlook.ContactItem
Set ns = myOlApp.GetNamespace("MAPI")
Set oContact = ActiveExplorer.Selection.Item(1)
' use oContact.FullName to search on the name
strFilter = oContact.Email1Address

Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox)
txtSearch = "from:(kirsten collins)" & strFilter
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub

I get a type mismatch error on the "Set oContact = ActiveExplorer.Selection.Item(1)" line

Could someone please help?
 

cale may

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
No. I didn't understand that part. I will try tomorrow.
Is there a macro that I can set up for a person's name.
I spend 1 hour a day filtering by peoples names. I would like to find a macro that I can click and it does it for me.
Thank You so much for your help.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B Need help getting my outlook to create web links automatically when I type in the web address Using Outlook 1
P PST file is getting huge under POP 3 Using Outlook 3
N contact notepad 'style' getting changed after clicking and running Activities Using Outlook 2
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
D Close Oulook after sending emails via vba without outbox getting stuck. Outlook VBA and Custom Forms 1
William getting custom form to load category colors Outlook VBA and Custom Forms 4
C Getting back previous computer owner Outlook email Using Outlook.com accounts in Outlook 1
B Recipient of a forwared message getting multiple emails Using Outlook 2
S Outlook 2010 I am getting error code 0x8DE00006 'the operation failed'. outlook 2010 send/receive progress Using Outlook.com accounts in Outlook 2
S Mails getting downloaded multiple times Using Outlook 1
Rory Campion Not getting a warning when a shared calendar item has been updated by someone else Using Outlook 2
E Getting IMAP email into existing pst file Using Outlook 6
J Just installed Outlook 2010 on computer and user is getting a 0x80004005 error Using Outlook.com accounts in Outlook 1
R Getting a colleagues appointments and calendar entries Using Outlook 1
E Getting Outlook full name correct with AddressLayout Using Outlook 1
P I'm getting an error when opening Outlook "Mobile me stopped working Using Outlook 1
D Need Help with Script. Keep getting Runtime Error 438 BCM (Business Contact Manager) 4
R Need help getting BCM to work with my Outlook 2014 Using Outlook 4
D Help Getting Started? BCM (Business Contact Manager) 4
P I am getting an error msg = cannot open file access denied Using Outlook 3
K why is a user getting email respond for invite respond that she didn't set up. Using Outlook 3
B email getting cut off Using Outlook 9
L Need help getting calendar/contacts/tasks/notes back! Using Outlook 3
M Email Format getting changed to Plain Text Using Outlook 1
G Outlook 2013: Getting meeting invites in OWA format Using Outlook 9
M Getting messages from multiple email address Using Outlook 1
B not getting email from people Using Outlook 3
L Outlook 2010 - Keep getting "Corrupted File" Msgs Using Outlook 4
mrje1 Assigned Categories keep getting deleted in mail, bug? How to fix if possible? Using Outlook 5
Commodore Why some RSS feeds stop getting updates? Using Outlook 12
M All e mails seem to be getting blocked BCM (Business Contact Manager) 7
J Send/receive getting stuck Using Outlook.com accounts in Outlook 1
R Getting my Claendar additions to appear in Outlook Today Using Outlook 7
J Getting Contact Name to show on Calendar Using Outlook 2
D outlook getting stuck receiving Using Outlook 1
K Getting default beep when permanently deleting email even though sound is turned off Using Outlook 1
C IN MY 2007 OUTLOOK. Problem getting OUTBOX to SEND E-Mails Using Outlook 2
B Getting: Your Out of Office settings cannot be displayed, because the server is currently unavailable. Try again later. Using Outlook 0
T PST file keeps getting corrupted Using Outlook 3
S I keep getting a not responding message and a gray screen__when i change folders Using Outlook 3
O I suddenly can't open Outlook after getting a microsoft automatic update. Using Outlook 2
H getting error code 0x800ccc18 when sending/receiving e-mails Using Outlook 2
M Upgrading HUB 2010 to SP1, getting error "There should only be a single RMS Shared Identity user" Exchange Server Administration 1
L I am getting error code OX800CCC78 when I try to send and email in Outlook 2003 Using Outlook 1
S Outlook 2010 Meeting Requests getting stuck in drafts folder Using Outlook 1
S Email are getting saved in to draft folder while send from OWA 2010 runing on exhange server 2010 Exchange Server Administration 4
E Getting all items in Outlook contact activities to display properly Using Outlook 2
X Not getting new move request exchange 2010 Exchange Server Administration 1
D Outlook 2003 is getting an error when trying to open an exchange 2010 mailbox Exchange Server Administration 5
Y MICROSOFT OUTLOOK 2007 - i KEEP GETTING THE "ENTER NETWORK PASSWORD" BOX POPPING UP - IT IS ALREADY Using Outlook 4
Similar threads


















































Top