I'm not completely sure where this exactly happens in the background. But when executing the close line in the PMP handler you are never reaching next line. The call just dies.
PMPHandler attached to PMPPage so closing the host object from within the child object is always unsafe. I assume somewhere inside it just causing the disconnect from context exception.
Anyways to overcome this you should redirect the close operation out of PMPHandler. The easiest way is using events. Please find attached modified macro which fixes your issue and closes PMP from button press.
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
myIntercad – an integrated tool for SolidWorks Professionals
Test_fix.swp.zip 25.3 KB
Your solution is perfect, thank you very much for your help!