Either the $ppt variable isn't initialized properly (which I doubt, since it didn't complain about the NewPresentation call) or the Add or NewPresentation functions didn't work as you expected. I'd suggest adding a check on the success of the NewPresentation()->Add() call (similar to the way you'd do it for an open).