After coding this to success, I added it to the Macro section of the forum.
It can be found here.
Many thanks to all.
For more information, see the wiki Searching the Forum for Answers section.