Pitcairn, Robert, Commendator of Dunfermline, Scottish Sec of State