![]() |
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 Everyone,
I wrote a Macro that takes the selected Email, removes some text from the subject (e.g. “, FW:” etc.) and performs a search on all Emails containing this string. The results of the search are displayed in a new window. Sometimes it works as expected, and sometimes I get an error: This is how the error object holds these values: Description: "The operation failed." HelpContext: 1000440 Number: -2147219964 From when it fails, Instant search stops responding in the main window as well. All this until I restart Outlook (2007). Interestingly, when I change the Macro to display the results in the current (main) window, it always work without any problem. The code: ****************************** Sub SearchByStrippedSubject() Dim app As New Outlook.Application Dim item As Object Dim email As MailItem Set email = app.ActiveExplorer.Selection.item(1) Dim myExplorer As Explorer On Error Resume Next Set myExplorer = app.Explorers.Add(app.Session.GetDefaultFolder(olF olderInbox), olFolderDisplayNormal) Dim filter As String filter = email.Subject filter = Replace(filter, " ", "") filter = Replace(filter, "FW: ", "") filter = Replace(filter, "", "") filter = Replace(filter, "FW:", "") filter = Replace(filter, " (handled)", "") filter = Replace(filter, "(handled)", "") filter = Replace(filter, " (handling)", "") filter = Replace(filter, "(handling)", "") filter = Chr(34) + filter + Chr(34) On Error Resume Next myExplorer.Search filter, olSearchScopeAllFolders If Err.Number 0 Then MsgBox Err.Description Err.Clear myExplorer.Close Exit Sub End If myExplorer.Display End Sub ****************************** Any ideas? TIA, -- Eylon |
#2
|
|||
|
|||
![]()
This runs in the Outlook VBA project? If so don't use New
Outlook.Application, use either Application or set app = Application. See if that helps. The error is a generic MAPI_E_COLLISION error, and that usually occurs if you try to create a folder with the same name as another folder in the same hierarchy location. So it's possible that displaying a new Explorer is what's doing that and you might have to fall back on just using the existing Explorer. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Eylon" wrote in message ... Hello Everyone, I wrote a Macro that takes the selected Email, removes some text from the subject (e.g. “, FW:” etc.) and performs a search on all Emails containing this string. The results of the search are displayed in a new window. Sometimes it works as expected, and sometimes I get an error: This is how the error object holds these values: Description: "The operation failed." HelpContext: 1000440 Number: -2147219964 From when it fails, Instant search stops responding in the main window as well. All this until I restart Outlook (2007). Interestingly, when I change the Macro to display the results in the current (main) window, it always work without any problem. The code: ****************************** Sub SearchByStrippedSubject() Dim app As New Outlook.Application Dim item As Object Dim email As MailItem Set email = app.ActiveExplorer.Selection.item(1) Dim myExplorer As Explorer On Error Resume Next Set myExplorer = app.Explorers.Add(app.Session.GetDefaultFolder(olF olderInbox), olFolderDisplayNormal) Dim filter As String filter = email.Subject filter = Replace(filter, " ", "") filter = Replace(filter, "FW: ", "") filter = Replace(filter, "", "") filter = Replace(filter, "FW:", "") filter = Replace(filter, " (handled)", "") filter = Replace(filter, "(handled)", "") filter = Replace(filter, " (handling)", "") filter = Replace(filter, "(handling)", "") filter = Chr(34) + filter + Chr(34) On Error Resume Next myExplorer.Search filter, olSearchScopeAllFolders If Err.Number 0 Then MsgBox Err.Description Err.Clear myExplorer.Close Exit Sub End If myExplorer.Display End Sub ****************************** Any ideas? TIA, -- Eylon |
#3
|
|||
|
|||
![]()
Thanks Ken,
I run it from the Tools menu - Macro - Macros. Guess it makes it a VBA project. Tried your solution but it behaves the same (first time works, second results in error, then must restart for normal GUI Instant search to work in main window). It does behave as expected if I run it from the GUI by right-clicking Personal Folders in the Navigation Pane, Selectin Open in New Window, and entering the search in the Instant Search box. With the macro I try to mimic the same action. Any other ideas? Thanks again, -- Eylon "Ken Slovak - [MVP - Outlook]" wrote: This runs in the Outlook VBA project? If so don't use New Outlook.Application, use either Application or set app = Application. See if that helps. The error is a generic MAPI_E_COLLISION error, and that usually occurs if you try to create a folder with the same name as another folder in the same hierarchy location. So it's possible that displaying a new Explorer is what's doing that and you might have to fall back on just using the existing Explorer. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Eylon" wrote in message ... Hello Everyone, I wrote a Macro that takes the selected Email, removes some text from the subject (e.g. “, FW:” etc.) and performs a search on all Emails containing this string. The results of the search are displayed in a new window. Sometimes it works as expected, and sometimes I get an error: This is how the error object holds these values: Description: "The operation failed." HelpContext: 1000440 Number: -2147219964 From when it fails, Instant search stops responding in the main window as well. All this until I restart Outlook (2007). Interestingly, when I change the Macro to display the results in the current (main) window, it always work without any problem. The code: ****************************** Sub SearchByStrippedSubject() Dim app As New Outlook.Application Dim item As Object Dim email As MailItem Set email = app.ActiveExplorer.Selection.item(1) Dim myExplorer As Explorer On Error Resume Next Set myExplorer = app.Explorers.Add(app.Session.GetDefaultFolder(olF olderInbox), olFolderDisplayNormal) Dim filter As String filter = email.Subject filter = Replace(filter, " ", "") filter = Replace(filter, "FW: ", "") filter = Replace(filter, "", "") filter = Replace(filter, "FW:", "") filter = Replace(filter, " (handled)", "") filter = Replace(filter, "(handled)", "") filter = Replace(filter, " (handling)", "") filter = Replace(filter, "(handling)", "") filter = Chr(34) + filter + Chr(34) On Error Resume Next myExplorer.Search filter, olSearchScopeAllFolders If Err.Number 0 Then MsgBox Err.Description Err.Clear myExplorer.Close Exit Sub End If myExplorer.Display End Sub ****************************** Any ideas? TIA, -- Eylon |
#4
|
|||
|
|||
![]()
Only other idea would be to display the new Explorer before running Search
on it. Otherwise, no ideas other than using the original Explorer. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Eylon" wrote in message ... Thanks Ken, I run it from the Tools menu - Macro - Macros. Guess it makes it a VBA project. Tried your solution but it behaves the same (first time works, second results in error, then must restart for normal GUI Instant search to work in main window). It does behave as expected if I run it from the GUI by right-clicking Personal Folders in the Navigation Pane, Selectin Open in New Window, and entering the search in the Instant Search box. With the macro I try to mimic the same action. Any other ideas? Thanks again, -- Eylon |
#5
|
|||
|
|||
![]()
Thanks again Ken,
Displaying before did not help. Anyone else have any ideas? -- Eylon "Ken Slovak - [MVP - Outlook]" wrote: Only other idea would be to display the new Explorer before running Search on it. Otherwise, no ideas other than using the original Explorer. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Instant Search, Advanced Find, Search Folders, and Windows Desktop | [email protected] | Outlook - General Queries | 2 | October 31st 08 06:37 PM |
Instant Search? | Candy | Outlook - General Queries | 6 | January 24th 08 08:45 PM |
SPEED: Instant Search vs. Search Folders | [email protected] | Outlook - General Queries | 0 | November 21st 07 03:18 PM |
Instant Search - | Brenda | Outlook - General Queries | 1 | August 7th 07 11:23 AM |
2007 search box and instant search invite, remove them | jeffrey | Outlook - General Queries | 2 | February 28th 07 04:08 PM |