O
Olivier Langlois
Hi,
I am using the following VBA function:
Function FindOrCreateFolder(inputFolder As Outlook.MAPIFolder,
folderName As String) As Outlook.MAPIFolder
Dim curFolder As Outlook.MAPIFolder
For Each curFolder In inputFolder.Folders
If folderName = curFolder.Name Then
Set FindOrCreateFolder = curFolder
Exit Function
End If
Next curFolder
Set FindOrCreateFolder = inputFolder.Folders.Add(folderName)
End Function
The reason why it is looping through all folders is that my folder
names are number ie: ('1234'). I have tried to use
inputFolder.Folders.Find(folderName) but it did not work because VBA
was interpreting the folderName parameter as an integer representing an
index. My workaround worked fine but it is becoming very slow as the
number of folders is a few thousands and still growing.
So now, I am looking for solution suggestions. Is there a way to
specify to VBA to not perform the conversion string to integer and call
the right version of Find()? Also, I have read in Sue Mosher book that
using CDO API was significantly faster than the Outlook object Model
API for accessing folder collections. This is something that I am
willing to try. Is there someone that could tell me what would look
like the CDO version of my FindOrCreateFolder() function?
Thank you very much!
Olivier Langlois
http://www.olivierlanglois.net
I am using the following VBA function:
Function FindOrCreateFolder(inputFolder As Outlook.MAPIFolder,
folderName As String) As Outlook.MAPIFolder
Dim curFolder As Outlook.MAPIFolder
For Each curFolder In inputFolder.Folders
If folderName = curFolder.Name Then
Set FindOrCreateFolder = curFolder
Exit Function
End If
Next curFolder
Set FindOrCreateFolder = inputFolder.Folders.Add(folderName)
End Function
The reason why it is looping through all folders is that my folder
names are number ie: ('1234'). I have tried to use
inputFolder.Folders.Find(folderName) but it did not work because VBA
was interpreting the folderName parameter as an integer representing an
index. My workaround worked fine but it is becoming very slow as the
number of folders is a few thousands and still growing.
So now, I am looking for solution suggestions. Is there a way to
specify to VBA to not perform the conversion string to integer and call
the right version of Find()? Also, I have read in Sue Mosher book that
using CDO API was significantly faster than the Outlook object Model
API for accessing folder collections. This is something that I am
willing to try. Is there someone that could tell me what would look
like the CDO version of my FindOrCreateFolder() function?
Thank you very much!
Olivier Langlois
http://www.olivierlanglois.net