See, for example:
https://www.msofficeforums.com/word-...html#post46903
and, for different elements from a selected item to be output to different content controls, see:
https://www.msofficeforums.com/word-...tml#post120392
FWIW, changing the header/footer content doesn't even require a macro - just one or more STYLEREF fields in conjunction with IF tests.