I know that I searched with Google when I was looking for methods for the Word macro that does this. It came up with several hits, depending on your programming language... Most of the methods are slow...
I ended up using a different method, which is possible since my source is Word. I save it as pdf within Word (as of 2007 it is a standard functionality). I open the PDF in fontforge and select the font I want. I don't know if it is intended, but the PDF already contains a subset of the font with only the used characters. So, save the font in FontForge as either ttf or otf and you have a subset of the font.