Very nice K. Scope IS a crucial concept, and Saban, it is therefore crucial to understand it, and use it properly. Help is very good, but I also suggest doing actual tests for yourself.

Make variables that are in scope within a procedure, within a module, and globally. Make tests so you can see where a variable goes out of scope...which is the thing that is so crucial!

And NEVER forget to destroy object variables that are not being used. Even if you going to create another one just like it. If THAT variable is not being used anymore, destroy it.

So your set doc = documents.add should always, somewhere, have a set doc = nothing. This is, in fact, a good part of testing for scope.