This morning I ran into a problem that frustrated me to no end, until I finally figured it out. The answer was of course in the online help…
I had a class that processed people associated with a file. Each person is assigned (in creation order) a number, starting with 1. The class load the person documents when the class is initiated, and store the info in an array.
What happend is that I got the "Subscript out of range" error on a particular file. What I found was that it had 10 person documents, numbered 2 through 11. This is of course 10 persons, so the array was dimmed as 1 to 10. When I hit the 10th person, it had the number 11 and my code blew up when I tried to put the info into the 11th (non-existing) array element.
OK, this should be easy to fix. Just check the person number field and if the value is larger that the size of the array, redim the array using Redim Preserve. Nope, this line now gave me the same error, just in a different location, on the line where I do Redim Preserve person(1 to personcount) as NotesDocument.
The solution was easy. You can not change the lower bound of the array, so the correct code would be Redim Preserve person(personcount) as NotesDocument instead. Then it worked.
Just a small tip I wanted to share.