Thanks Russ, this is great stuff. It solved my problem. And tipping me off that weird things happen at the last paragraph of a flow also helped me to fix another problem I was having, where I was trying to select the end of a section at the end of a file, with no following heading to define the end. Who says dummies aren't useful! (dummy Pgfs!)
Your code in getLastPgf() seems to imply that what the API gives you as the last Pgf (textFrame.LastPgf) might not actually be the last pgf, and so you have to slap it around to make it tell you something more useful. Is that correct? You get the last pgf, but then you check it to see if it's valid.