Call the function from the print button, but put the error trap in the function itself, where you open the file.