If Scotland attacks you, you wage a war of defence, hence the Pope will not excommunicate you. Try to draw them into a war, that way you can defend and take them over.