 On February 17, 1779 he was named captain of the recently created Company of Naval Cadets of the Department of Ferrol.He remained in this position until he was appointed viceroy and captain general of New Granada and president of the "Audiencia" of Santa Fe de Bogotá by Antonio Valdez, minister of the Indies (1788).By this time he was commander of a squadron.