A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro for Instant Search in new Window, failes Instant search (OL2



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old February 3rd 09, 05:56 PM posted to microsoft.public.outlook.program_vba
Eylon
external usenet poster
 
Posts: 3
Default Macro for Instant Search in new Window, failes Instant search (OL2

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
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 06:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.