Hi,

Thanks for your reply Gollem. I changed it from a function to a sub. But then when I try to run it as a "RunCode" in my macro I get a different message, this time stating that there is no object in the database with the name I have specified.

The only option there is in "RunCode" is "Function Name". So maybe my code still has to be a function for it to be executed in a macro?

Back to square one..