Outlook 2007 E-Mail Search

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Per our earlier posts, we created a macro that searches all e-mails to or from the contact that we select or open, and the macro bullet is in the Outlook Toolbx and in the Contact form itself.

But now, it works if the contact is opened, but not where I just select the contact.

The error that shows up is:

The macro error is:

Run-time error '91':

Object variable or With block variable not set.

And when I debug, the line Set oContact = myOlApp.ActiveInspector.CurrentItem is yellowed...'

'

Is there a way to fix this right away?

And the full macro you gave me is:

Sub Search_By_Address_From_and_To()


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 = myOlApp.ActiveInspector.CurrentItem


' use oContact.FullName to search on the name

strFilter = oContact.Email1Address


Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox)


txtSearch = "from:" & strFilter & " OR to:" & strFilter

myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders


Set myOlApp = Nothing


End Sub

Thanks
 
You need the GetCurrentItem function.

Replace

Set oContact = myOlApp.ActiveInspector.CurrentItem

with

Set oContact = GetCurrentItem()

and paste the Function in the module after the search_by-address macro.
 
Works great. Thanks much.

Is there way to search all contact folders per a phone number.....regardless of whether this is a . or a - between the numbers? Is there a macro to do the search...as adding the business phone field to the criteria area...is tnot working.
 
As long as the number is not entered in 2025551212 format without separators, try spaces between the numbers - "202 555 1212"

The query would be:

businessphone:"202 555 1212"
 
Thank you...that doesn't work........any otherway to try?

There phone numbers like (713) 777-7777 or 713.777.7777 or 713-777-7777
 
It worked here on the first format, I don't have any numbers in the other two formats - Outlook keeps converting them to the first one. I have some that synced from my phone and it won't find them, but i knew it wouldn't because outlook don't do partial word searches starting in the middle of a word.

Outlook treats space, periods and dashes as word separators, so it just sees the numbers.

Is the number in the business phone field? You can't search for a number in any field using that qualifier- use just "202 555 1212" to search all fields - this will find in Notes too.
 
so where do you go to ....so you search all fields? thanks
 
I just typed "202 555 1212" in the Instant Search field.

Ohhhhh.... you are using Outlook 2007. Let me check on that, I seem to recall Instant Search was lacking.

It's working here... slow as molasses, but it is finding the standard format number.

search-phone.png
 
thank you..it doesn't work...I have it set to search all folders....i put in the numbers 713 777 7777 with no other stuff...and nothing shows up as I tried it with my phone number which should go right to my contact of me

- - - Updated - - -

thank you..it doesn't work...I have it set to search all folders....i put in the numbers 713 777 7777 with no other stuff...and nothing shows up as I tried it with my phone number which should go right to my contact of me

- - - Updated - - -

thank you..it doesn't work...I have it set to search all folders....i put in the numbers 713 777 7777 with no other stuff...and nothing shows up as I tried it with my phone number which should go right to my contact of me
 
I found the Advanced Find and how to do it to phone numbers....that's what works!

thanks
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
D Outlook 2007 e-mail header- How to set font & font size in received message headers ? Using Outlook 2
C in outlook 2007-Contact Group-One name have 3 mail id-its possible? Using Outlook 3
D Recover deleted Outlook 2007 e-mail account Using Outlook 1
L Outlook 2007 Macro Reply to E-mail Using Outlook 16
L Outlook 2007 Search Through E-Mail Using Outlook 41
L Outlook 2007 E-Mail From Selected Task Using Outlook 18
R Outlook 2007 junk mail Using Outlook 4
F Using Outlook 2007 as an IMAP Mail Station Without Saving Data Locally Using Outlook 2
L Outlook 2007 Distibution E-mail Structure Using Outlook 5
W Combine Mail Merge to Distribution List with Auto Attachments - Outlook 2007 Using Outlook 1
D Problem with MS mail and outlook 2007 OS Windows 8 Using Outlook 1
D Can't Use Contacts with Mail & iCloud in Outlook 2007 Using Outlook 7
L Outlook 2007 E-mail Search Using Outlook 19
P help me plase !!! outlook 2007 I can see mail Bcc Using Outlook 1
C MS Mail and Outlook 2007 Using Outlook 3
B Outlook 2007 Mail Accounts Order? Using Outlook 2
L Outlook 2007 - How to remove account without removing mail folders? Using Outlook 4
D Sort e-mail by sender's domain - Outlook 2007 Using Outlook 2
N Providing a reference to incoming mail in outlook 2007 BCM (Business Contact Manager) 2
W Outlook exp. 2007 problems - won't receive new mail Using Outlook 1
A Outlook 2007 Mail Merge not working anymore Using Outlook 1
L How can I delete stationery from Actions, New Mail Message Using in outlook 2007? Using Outlook 6
S Outlook 2007 Macro for replying to an e-mail. Outlook VBA and Custom Forms 1
C Importing emails/contacts to Outlook 2007 from Windows Mail Outlook VBA and Custom Forms 3
C How do I enable a link in an e-mail in Outlook 2007? Using Outlook 4
A How to Sort by Unread and then Read mail in Outlook 2007 Using Outlook 7
D Outlook 2007 Will Not Send Mail From C# Application Outlook VBA and Custom Forms 7
N Automating Outlook 2007 problem with sending mail Outlook VBA and Custom Forms 1
D Disable Junk E-mail Filter in Outlook 2007 Using Outlook 13
X open specific e-mail messages in outlook 2007 c# Outlook VBA and Custom Forms 1
T need help w/ sending an e-mail -- outlook 2007 addin Outlook VBA and Custom Forms 2
B Outlook 2003/2007 and New Mail Desktop Alerts Outlook VBA and Custom Forms 4
D Outlook 2007 Recovering E-Mails Using Outlook 0
W Transfer Outlook 2016 autocomplete file to Outlook 2007 Using Outlook 1
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
S Outlook 2007 - Automatic purge fail Using Outlook 0
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
S Verwendung von Outlook 2007 Using Outlook 0
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2

Similar threads

Back
Top