customization – Can’t install this custom `Palette`


I want to install the following Palette under the “Palette” menu (using Mathematica 12.1.1.0 for MacOs), and have the palette remember its position on closing:

CreatePalette(
 Column(
  (Button(Style(#1, 20, FontFamily -> "Calibri"), 
  FrontEndTokenExecute(InputNotebook(), "Style", #1), 
  Appearance -> "Palette", 
  ImageSize -> 250) & )
 /@ {"Title", "Subtitle", "Subsubtitle", "Section", "Subsection",
  "Subsubsection", "Text", "DisplayFormula", "DisplayFormulaNumbered"},
 Spacings -> 0))

My questions are:

  1. I have tried to save the palette but cannot. I can save a notebook containing just the code, of course – but then if I open that notebook using “Install palette” under the “Palette” menu, when I click “OK” Mathematica beeps and says there’s no such directory.

  2. I would like the palette to appear in the position it was last used. I tried adding the code offered here to the cell containing the palette instructions, like so:

    CreatePalette(
     Column(
      (Button(Style(#1, 20, FontFamily -> "Calibri"), 
      FrontEndTokenExecute(InputNotebook(), "Style", #1), 
      Appearance -> "Palette", 
      ImageSize -> 250) & )
     /@ {"Title", "Subtitle", "Subsubtitle", "Section", "Subsection",
      "Subsubsection", "Text", "DisplayFormula", "DisplayFormulaNumbered"},
     Spacings -> 0));
    
    SetOptions(
     NotebookOpen@%, 
     { Saveable -> True, ClosingAutoSave -> True }
    )
    

But this produces the following error:

enter image description here

So (a) how do I install the palette, and (b) how do I save its position?