For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > August 2005 > how can i speed up this loop?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how can i speed up this loop?
pb

2005-08-25, 7:56 am

using the following code to search through all the contacts in a outlook
folder. This process can be slow if a lot of contacts are in the folder.
I'm trying to experiment with other loop methods; the following were
suggested; GetFirst/GetNext - does anyone know how i can modify the below
code to loop through records using GetFirst/GetNext method?

Dim ol As Outlook.Application
Dim olns As NameSpace
Dim objContactsFolder As Outlook.MAPIFolder
Dim iCount As Integer
Dim objContacts As Outlook.Items
Dim objContact As Object

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set objContactsFolder = olns.Folders("test").Folders("Foldertest")
Set objContacts = objContactsFolder.Items

' Process the changes
iCount = 0

For Each objContact In objContacts
'''''do something-make changes....etc
iCount = iCount + 1
Next
Veign

2005-08-25, 6:55 pm

You could try the ADO way:
http://trillian/vrc_codeview.asp?type=app&id=68

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--


"pb" <pb@discussions.microsoft.com> wrote in message
news:AD5077E5-E18E-472E-A88E-65E044AB68DA@microsoft.com...
> using the following code to search through all the contacts in a outlook
> folder. This process can be slow if a lot of contacts are in the folder.
> I'm trying to experiment with other loop methods; the following were
> suggested; GetFirst/GetNext - does anyone know how i can modify the below
> code to loop through records using GetFirst/GetNext method?
>
> Dim ol As Outlook.Application
> Dim olns As NameSpace
> Dim objContactsFolder As Outlook.MAPIFolder
> Dim iCount As Integer
> Dim objContacts As Outlook.Items
> Dim objContact As Object
>
> Set ol = New Outlook.Application
> Set olns = ol.GetNamespace("MAPI")
> Set objContactsFolder = olns.Folders("test").Folders("Foldertest")
> Set objContacts = objContactsFolder.Items
>
> ' Process the changes
> iCount = 0
>
> For Each objContact In objContacts
> '''''do something-make changes....etc
> iCount = iCount + 1
> Next



pb

2005-08-25, 6:55 pm

link doesn't work
its the database processing part which is taking a long time

"Veign" wrote:

> You could try the ADO way:
> http://trillian/vrc_codeview.asp?type=app&id=68
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:AD5077E5-E18E-472E-A88E-65E044AB68DA@microsoft.com...
>
>
>

Veign

2005-08-25, 6:55 pm

Should have been:
http://www.veign.com/vrc_codeview.asp?type=app&id=68

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--


"pb" <pb@discussions.microsoft.com> wrote in message
news:8AAA3B27-CE40-4119-B259-1F705A909408@microsoft.com...[color=darkred]
> link doesn't work
> its the database processing part which is taking a long time
>
> "Veign" wrote:
>
outlook[color=darkred]
folder.[color=darkred]
below[color=darkred]


pb

2005-08-26, 3:55 am

this looks like it will only work with exchange, however, i'm not running
exchange.
How would u modify this line to reflect no exchange server:

CNN.Open "Provider=Microsoft.JET.OLEDB.4.0;" & _
"Exchange 4.0;" & _
"MAPILEVEL=Outlook Address Book\;" & _
"PROFILE=Outlook;" & _
"TABLETYPE=1;" & _
"DATABASE=c:\temp" 'You may need to change this

"Veign" wrote:

> Should have been:
> http://www.veign.com/vrc_codeview.asp?type=app&id=68
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:8AAA3B27-CE40-4119-B259-1F705A909408@microsoft.com...
> outlook
> folder.
> below
>
>
>

Veign

2005-08-26, 6:55 pm

Did you try it?

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--


"pb" <pb@discussions.microsoft.com> wrote in message
news:1A515AD9-F274-48E3-BA61-80545953DD7E@microsoft.com...[color=darkred]
> this looks like it will only work with exchange, however, i'm not running
> exchange.
> How would u modify this line to reflect no exchange server:
>
> CNN.Open "Provider=Microsoft.JET.OLEDB.4.0;" & _
> "Exchange 4.0;" & _
> "MAPILEVEL=Outlook Address Book\;" & _
> "PROFILE=Outlook;" & _
> "TABLETYPE=1;" & _
> "DATABASE=c:\temp" 'You may need to change this
>
> "Veign" wrote:
>
were[color=darkred]
the[color=darkred]


pb

2005-08-27, 6:55 pm

This actually worked very well after i modified it a little.....very fast and
furious

"Veign" wrote:

> Did you try it?
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:1A515AD9-F274-48E3-BA61-80545953DD7E@microsoft.com...
> were
> the
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com