Place that code in a Module, and then call it from your code.