Doctor concerned about weight gain

I'm 32 weeks and my doctor advised that I not gain any more weight and made a point to let me know it was ok to lose a couple of pounds. Can you say OUCH. Talk about a touchy subject... I've gained a total of 40 lbs thus far and I'm pretty sure it's because I went a little haywire in my second trimester with giving into all my cravings. I'm not a big junk food eater and I thought I was doing ok, but apparently not. Any tips or advice on how to not gain anymore or even lose some in the third trimester?? Pregnancy workout suggestions? (Is it even possible to work a 40 hour job, get a good workout each day and sleep a full 8-9 hours a night?!?!)