I'm not 100% certain but I could swear there is a UDF for this already, or at least a posted script as I did one and I forget who but someone else did one as well at the same time and we compared notes, so I know it's on the board somewhere, you just need to search and find it.