If there's not an editor (or the editor is not the active item, then there could be an error. Added a try/catch