Calendar Search

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
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
Outlook 2007
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
Outlook 2007
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
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
So delete that line??
 

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
Outlook 2007
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
Outlook 2007
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
Outlook 2007
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
Outlook 2007
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
Outlook 2007
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
Outlook 2007
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.
Thread starter Similar threads 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
F 2010 Shared mailbox Search Issue [Specifically shared calendar] Using Outlook 3
B MS Office 2010-calendar search feature; whenever I invoke this, I get an error message and the s/w closes MS Office and restart it Using Outlook 2
R Calendar item shows up every day as a reminder, even though it cannot be located through any search. Using Outlook 1
K UDF with formula not showing on Calendar custom view. Outlook VBA and Custom Forms 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
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
O Calendar - appointment templates and categories Using Outlook 1
HarvMan Outlook 365 Calendar Using Outlook 12
A calendar invites sent from Microsoft Outlook to Mac Outlook is not working Calendar Printing Assistant 3
P Categorize in Calendar not listed under tags in Office 365 (Office 2016) Using Outlook 5
O Export Outlook calendar appointments by filters and date range Outlook VBA and Custom Forms 1
J Weekend View in Calendar Using Outlook 1
D Add date next to day name in Outlook Today calendar view Using Outlook 1
A Birthdays from .csv to Calendar - arriving day behind Using Outlook 5
C Put Day of Year into Outlook Calendar Outlook VBA and Custom Forms 2
J can't sync outlook calendar contacts with iphone ipad Using Outlook 4
C Outlook Calendar Using Outlook 1
L Deleting Office 365 calendar appt w/o emailing invitees Using Outlook 3
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
D Outlook 2016 Migrate 'On My Computer' (local storage) Calendar from Mac Outlook to Exchange Account Using Outlook 5
TomHuckstep Outlook 2016 Limit the number of days syncing from Google Calendar Using Outlook 1
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
Jennifer Murphy Add birthdays to calendar Using Outlook 7
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
K Accentuating today in Outlook calendar month view Using Outlook 2
V iCloud calendar sync problems Using Outlook 13
J Copy to calendar function no longer working in outlook 365 Using Outlook 5
T why are the calendar icons different for different accounts Using Outlook 2
D Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
P OWA Settings->Calendar->Events from Email; Setting changes do not hold Using Outlook 1
W Outlook Calendar does not save view any longer! Using Outlook 3
M move to iCloud not working in outlook calendar Using Outlook 12
C Shading every other week on monthly calendar Using Outlook 4
cricket1001 Problems with calendar syncing Using Outlook 0
cricket1001 Shade non-working days in calendar Using Outlook 0
F My hotmail calendar is not syncing with my outlook but my email is Using Outlook 3
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
T Outlook 2010 Advice on syncing OL2010 Calendar and Outlook app Using Outlook 0
Similar threads


















































Top