Place the code in its own module, not in the ThisDocument module. You can find a similar example here … List objects used in a series of reports. The second example puts the results in a full client document, whereas the first uses a text file, but otherwise are similar.
Dwayne Hoffpauir (BOB member since 2002-09-19)