I've managed to "borrow" bits of code from various sources, and have finally got this working fairly well (in SyteLine, but should work with any Progress application). Sorry, I can't remember where from, but thanks if you recognise any of your finely-crafted code!
If anyone wants a copy, get...