![]() |
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 all,
I have below code in a single Outlook Module. It runs as expected, but only when i include a line - which does not have any use for within the code! Which is calling a MsgBox function. This is probably a very simple explanation which I am not finding for this. Here is the code: Sub createMove() Dim myOlApp As New Application Dim namespace As namespace Dim inbFolder As MAPIFolder Dim myFolder As MAPIFolder Dim resFolder As MAPIFolder Dim aa, abc As String Dim objResult As Results Dim objSch As Search Dim item As MailItem Set namespace = myOlApp.GetNamespace("MAPI") Set inbFolder = namespace.GetDefaultFolder(olFolderInbox) Set resFolder = inbFolder.Folders("res") aa = "urn:schemas:mailheader:subject = 'test'" '& abc Const strS As String = "'Inbox\test'" Const strTag As String = "SubjectSearch" Set objSch = AdvancedSearch(Scope:=strS, Filter:=aa, SearchSubFolders:=True, Tag:=strTag) Set objResult = objSch.Results MsgBox "?" '' IF I DONT HAVE THIS IT WONT GET PAST THIS LINE! For Each item In objResult MsgBox "item: " & item.Subject item.Move resFolder Next End Sub |
#2
|
|||
|
|||
![]()
I think this is due to 'advancedsearch' being an asynchronous function and
therefore requires the advancedsearchcomplete event to await the result.... you may correct me if this is wrong ofcourse (?) ![]() "crazyv" wrote: Hello all, I have below code in a single Outlook Module. It runs as expected, but only when i include a line - which does not have any use for within the code! Which is calling a MsgBox function. This is probably a very simple explanation which I am not finding for this. Here is the code: Sub createMove() Dim myOlApp As New Application Dim namespace As namespace Dim inbFolder As MAPIFolder Dim myFolder As MAPIFolder Dim resFolder As MAPIFolder Dim aa, abc As String Dim objResult As Results Dim objSch As Search Dim item As MailItem Set namespace = myOlApp.GetNamespace("MAPI") Set inbFolder = namespace.GetDefaultFolder(olFolderInbox) Set resFolder = inbFolder.Folders("res") aa = "urn:schemas:mailheader:subject = 'test'" '& abc Const strS As String = "'Inbox\test'" Const strTag As String = "SubjectSearch" Set objSch = AdvancedSearch(Scope:=strS, Filter:=aa, SearchSubFolders:=True, Tag:=strTag) Set objResult = objSch.Results MsgBox "?" '' IF I DONT HAVE THIS IT WONT GET PAST THIS LINE! For Each item In objResult MsgBox "item: " & item.Subject item.Move resFolder Next End Sub |
#3
|
|||
|
|||
![]() You're right, AdvancedSearch works asynchronously. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize Outlook email: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Sun, 17 Jun 2007 20:57:01 -0700 schrieb crazyv: I think this is due to 'advancedsearch' being an asynchronous function and therefore requires the advancedsearchcomplete event to await the result.... you may correct me if this is wrong ofcourse (?) ![]() "crazyv" wrote: Hello all, I have below code in a single Outlook Module. It runs as expected, but only when i include a line - which does not have any use for within the code! Which is calling a MsgBox function. This is probably a very simple explanation which I am not finding for this. Here is the code: Sub createMove() Dim myOlApp As New Application Dim namespace As namespace Dim inbFolder As MAPIFolder Dim myFolder As MAPIFolder Dim resFolder As MAPIFolder Dim aa, abc As String Dim objResult As Results Dim objSch As Search Dim item As MailItem Set namespace = myOlApp.GetNamespace("MAPI") Set inbFolder = namespace.GetDefaultFolder(olFolderInbox) Set resFolder = inbFolder.Folders("res") aa = "urn:schemas:mailheader:subject = 'test'" '& abc Const strS As String = "'Inbox\test'" Const strTag As String = "SubjectSearch" Set objSch = AdvancedSearch(Scope:=strS, Filter:=aa, SearchSubFolders:=True, Tag:=strTag) Set objResult = objSch.Results MsgBox "?" '' IF I DONT HAVE THIS IT WONT GET PAST THIS LINE! For Each item In objResult MsgBox "item: " & item.Subject item.Move resFolder Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Explanation of Items count? | salad | Outlook and VBA | 2 | April 4th 07 07:14 PM |
Outlook crashes - no explanation - pop3 | boe | Outlook - General Queries | 2 | November 7th 06 04:40 PM |
How to change comment in conatct name "namecomment" | agporto | Outlook - Using Contacts | 1 | June 22nd 06 03:43 PM |
comment | eduardo vladimir | Outlook Express | 0 | February 17th 06 06:08 AM |
Pls comment my VBS | Tony WONG | Outlook and VBA | 1 | January 10th 06 04:34 PM |