You would have use scripts. As I have not actually needed to do this myself I can't give you a rapid answer but if you were to ask this question in the scripting forum I am sure that there are people in there who would not only be able to help you, but would be more than willing to help you.
TR