Calendar Search

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
I created thru you the macro that when I open up a contact and run the macro, it searches the calendar for the last name of the contact throughout the calendar.

But when I open the contact thru the shortcut (which we fixed just recently for the combobox macro), the macro for the calendar search does not run.

The macro you gave me was the folowing and the line : Set oContact = ActiveExplorer.Selection.Item(1): shows up yellow from the debug etc.

Any way to fix this one as well??

Thanks so much!!

Sub Search_Calender()

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.LastName


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


txtSearch = strFilter

myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders

Set myOlApp = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
thanks....but that did not solve it...and here is the line that goes yellow from the debug

strFilter = oContact.Email1Address
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It looks like its not detecting the contact and getting the email address from it.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
So why does the calendar search of the last name need to identify the email?

What to fix please?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i was basing that comment on your line in the post before it:

strFilter = oContact.Email1Address
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
you need a strfilter = line in it - so if you have two, then delete it, otherwise change it to the field you want to use.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
thank you...so this is the line and what words do I replace and what are the words to the calendar field please?

strFilter = oContact.Email1Address
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
and just to be clear, this macro works when I open up a contact from the folder, but doesn't work when I open up the contact from the shortcut in the calendar
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
strFilter = oContact.Lastname

This is what you'd use for the last name field. If it doesn't work, I don't know what is wrong. When you open the contact from a shortcut, It's not seen as the current item, which I causes problems with the macro.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
This is the macro you gave me that works from opening up the contact from the folder and not when I open up the contact from the shortcut to the contact.

So want to make this clear and see if there is anything you suggest that fixes it for running after I open up the contact from the shortcut to the contact.

And as a reminder, we fixed the similar problem with the other macros and you had me delete certain lines.

So, any new thoughts in details please?

Sub Search_Calender()

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.LastName


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


txtSearch = strFilter

myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders

Set myOlApp = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
And in another forum someone said the following, but it's not anything I understand.....so do you have a thought for fixing this code?

"a) You cannot set a variable that's declared as ContactItem to an object that is not a ContactItem.

b) ActiveExplorer.Selection(1) gives you a reference on the first selected item in a folder whereas ActiveInspector.CurrentItem gives you the ref on the open item.

That is if you want to access an open item, then don't use ActiveExplorer.Selection. You made the same error with your first code."
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
I replaced ActiveExplorer.Selection(1) with ActiveInspector.CurrentItem and it is now fixed!!

Thanks for your time as usual!!!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Glad you figured it out - I was visiting family over the weekend.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
As I have said in the past, this is not my area of expertise, and I truly appreciate your great support online!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S outlook 2007 calendar search Using Outlook 6
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
P Outlook search is not working at all for Calendar & Tasks Using Outlook 7
D Exchange to iOS Calendar Search Exchange Server Administration 5
J Calendar search failing & wrong indexlocation showing..OL2010 Using Outlook 3
A OL13 Calendar Search not finding most items Using Outlook 15
G Outlook 2013 - Search Returning All Calendar Entries Using Outlook 1
J Calendar Search by Category not showing expected results Using Outlook 7
B How can I narrow the search in my Outlook calendar? Using Outlook 0
C Outlook 2010 search for question mark in calendar Using Outlook 7
J Cannot search items within shared calendar Using Outlook 0
KeithJB iCloud calendar sync only works one way! Using Outlook 3
V Backup Calendar, Contacts, Tasks in an POP3 data file Using Outlook 3
O Unable to make changes to an existing Calendar entry Using Outlook 8
J VBA for outlook to compare and sync between calendar Outlook VBA and Custom Forms 1
A Meeting organizer calendar intermittently drops meeting after delegate sends invite Using Outlook 0
A Meeting organizer calendar intermittently drops meeting after delegate sends invite Exchange Server Administration 0
T Outlook 2010 Cannot edit Calendar entries in OL 2010. Using Outlook 1
M On behalf of not showing on calendar for boss Using Outlook 1
C Outlook 2016 Unable to delete Gmail IMAP calendar Using Outlook 2
A force outlook to default to MY calendar Using Outlook 3
O Carriage Return - Line Feeds - exporting Calendar events Using Outlook 0
K How to share multiple calendar items Using Outlook 1
P Calendar Day View only shows 1 all day event Using Outlook 0
Hobbes Outlook 365 Calendar spreads into second calendar Using Outlook 3
J Macro to Insert a Calendar Outlook VBA and Custom Forms 8
C Tracking Calendar Changes? Using Outlook 1
O Batch update calendar Using Outlook 3
P Outlook calendar and contacts sync problem-outlook disconnects Using Outlook.com accounts in Outlook 2
HarvMan Toggle between calendar and email in Outlook 365 Using Outlook 12
e_a_g_l_e_p_i Is it possible to transfer things from one calendar to another Using Outlook 2
M Outlook calendar is missing Using Outlook 2
A Any way to make Outlook Calendar invitations look right to Gmail/Google Calendar users? Using Outlook 3
O Calendar - Location: what happens when using my own way of entering locations Using Outlook 1
I Outlook is stuck at "Updating Calendar" Using Outlook 1
AmonRa Outlook 365 calendar - too much white space Using Outlook 0
M Cannot read the calendar Using Outlook 9
Horsepower What is best calendar practice for iMac Using Outlook 3
M Calendar greyed out Using Outlook 0
M Unable to share 2019 calendar Using Outlook 0
Fozzie Bear Accepted Zoom Invites deleting without going into Default Calendar - Office 2016 Mac Using Outlook 3
P Outlook 2013 Calendar Archiving Using Outlook 0
Fozzie Bear Sharing Birthday Calendar Using Outlook.com accounts in Outlook 3
M Calendar daily Appointments and printing Using Outlook 0
I Google Calendar <calendar-notification@google.com> appearing as a duplicate entry Using Outlook 2
L Sharing Calendar for Only Scheduling Using Outlook 2
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 3
E Work uses live accounts for emails for all employees. Can we use the outlook calendar to give the employees an universal work schedule calendar? Using Outlook 1
J O365 - Adding Shared Google Calendar ICS link issue in O365 Using Outlook 0

Similar threads

Top