Action has been approved to protect an iconic Scottish Borders building after “two decades of neglect and vandalism”.