J
John Gordon
My company has a custom Outlook form for handling vacation and sick time
requests. The form has fields for start date/time, end date/time, name,
etc.
I'm trying to write some code that will process a bunch of saved requests
and display some totals, but I'm having trouble. The code simply stops
working after about the 250th item in a folder. Any attempt to get at
the custom properties of any item after the 250th is a blank.
Here's some very simple code I wrote to illustrate the problem. It loops
through each saved item and checks if the "requestor" property contains
a capital I. (Our organization has a capital I in the name, and the org
name is appended to everyone's name, so everyone effectively has a capital
I in their name.)
The result of the code *should* be one capital I for every item in the
folder, but it ain't working that way. After about item 247 or so, it
stops working. No further items will register as containing a capital I
in the "requestor" property.
I've found various vague references claiming that this is a known bug,
that you cannot access more than 250 items in a folder, but that seems
preposterous. There must be a way around it.
Can anyone help? Thanks.
Code follows -------------------------------------
Option Explicit
Dim objapp, curr_fldr
Set objapp = CreateObject("Outlook.Application")
Set curr_fldr = objapp.ActiveExplorer.Currentfolder
Sub btnReport_Click()
Dim requestor, itm, itemNumber, Icount, tmpIcount, theLength
Dim idx, myChar, noIcount
On Error Resume Next
Icount = 0
noIcount = 0
For itemNumber = 1 to curr_fldr.Items.Count
Set itm = curr_fldr.Items(itemNumber)
requestor = " "
requestor = itm.UserProperties("Requestor")
theLength = Len(requestor)
tmpIcount = 0
For idx = 1 to theLength
myChar = Mid(requestor, idx, 1)
if myChar = "I" Then
tmpIcount = tmpIcount + 1
End If
Next
if tmpIcount = 0 then
noIcount = noIcount + 1
end if
Icount = Icount + tmpIcount
Set itm = Nothing
Next
MsgBox "Finished reading messages" & vbCrLf & "Icount = " & Icount _
& vbCrLf & "noIcount = " & noIcount
End Sub
Code ends -------------------------------------
requests. The form has fields for start date/time, end date/time, name,
etc.
I'm trying to write some code that will process a bunch of saved requests
and display some totals, but I'm having trouble. The code simply stops
working after about the 250th item in a folder. Any attempt to get at
the custom properties of any item after the 250th is a blank.
Here's some very simple code I wrote to illustrate the problem. It loops
through each saved item and checks if the "requestor" property contains
a capital I. (Our organization has a capital I in the name, and the org
name is appended to everyone's name, so everyone effectively has a capital
I in their name.)
The result of the code *should* be one capital I for every item in the
folder, but it ain't working that way. After about item 247 or so, it
stops working. No further items will register as containing a capital I
in the "requestor" property.
I've found various vague references claiming that this is a known bug,
that you cannot access more than 250 items in a folder, but that seems
preposterous. There must be a way around it.
Can anyone help? Thanks.
Code follows -------------------------------------
Option Explicit
Dim objapp, curr_fldr
Set objapp = CreateObject("Outlook.Application")
Set curr_fldr = objapp.ActiveExplorer.Currentfolder
Sub btnReport_Click()
Dim requestor, itm, itemNumber, Icount, tmpIcount, theLength
Dim idx, myChar, noIcount
On Error Resume Next
Icount = 0
noIcount = 0
For itemNumber = 1 to curr_fldr.Items.Count
Set itm = curr_fldr.Items(itemNumber)
requestor = " "
requestor = itm.UserProperties("Requestor")
theLength = Len(requestor)
tmpIcount = 0
For idx = 1 to theLength
myChar = Mid(requestor, idx, 1)
if myChar = "I" Then
tmpIcount = tmpIcount + 1
End If
Next
if tmpIcount = 0 then
noIcount = noIcount + 1
end if
Icount = Icount + tmpIcount
Set itm = Nothing
Next
MsgBox "Finished reading messages" & vbCrLf & "Icount = " & Icount _
& vbCrLf & "noIcount = " & noIcount
End Sub
Code ends -------------------------------------