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

Explanation on weird VB bahaviour W/O a comment



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 17th 07, 11:45 AM posted to microsoft.public.outlook.program_vba
crazyv
external usenet poster
 
Posts: 4
Default Explanation on weird VB bahaviour W/O a comment

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  
Old June 18th 07, 05:57 AM posted to microsoft.public.outlook.program_vba
crazyv
external usenet poster
 
Posts: 4
Default Explanation on weird VB bahaviour W/O a comment

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  
Old June 18th 07, 11:34 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Explanation on weird VB bahaviour W/O a comment




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


All times are GMT +1. The time now is 08:47 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.