How do I add "Menu - Format Cells - Alignment - Shrink to fit cell size" to Toolbars or Keyboard Shortcut Keys in Calc?

How do I add “Menu - Format Cells - Alignment - Shrink to fit cell size” to Toolbars or Keyboard Shortcut Keys in Calc?

I can’t find “Shrink to fit cell size” in “Tools - Customize - Toolbars - Add - Commands” or “Tools - Customize - Keyboard - Functions”.

(I use LibreOffice v5.2.1.2.)

You cannot find Shrink to fit cell size because it is not a menu item. Format Cells is a menu item which opens the dialog where Alignment tab contains Shrink to fit cell size.

Edit: Another alternative is to write your own macro and then create a toolbar item to execute the macro.

This routine is a toggle… When run, if normal it will Shrink selected cells and if Shrink is on it will turn off.

Sub ToggleShrinkCells
   Dim oCurrSel As Object
  oCurrSel = ThisComponent.getCurrentSelection()
  If oCurrSel.ShrinkToFit Then
     oCurrSel.ShrinkToFit = False
  Else
    oCurrSel.ShrinkToFit = True
  End If
End Sub