I have just recently switched from Micro$oft Office to LibreOffice, version 7.6.5.2, running in Ubuntu MATE 22.04. I’ve created a custom toolbar in Calc with the commands I use most often. There are two such features which I cannot seem to implement: “Delete Shift Up” and “Delete Shift Left”. The corresponding “Insert Shift Down” and “Insert Shift Right” commands DO exist, so I’m baffled as to why the Deletes have to rely an on extra step of the dialog box?!? I achieved this quite easily in Excel with two very simple macros which I assigned to toolbar buttons:
Sub DeleteShiftUp()
Selection.Delete Shift:=xlUp
End Sub
Sub DeleteShiftLeft()
Selection.Delete Shift:=xlToLeft
End Sub
Needless to say, these macros do not work in LO. I’ve tried recording a macro to capture the “Sheet > Delete Cells…” command and selecting the appropriate radio button. But this is what gets recorded…?!?
sub DeleteShiftLeft
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, Array())
end sub
I found a couple of functions in the included SFDocuments macros (ShiftLeft and ShiftUp) but they’re way overkill for what I’m needing (I had forgotten how verbose Basic can be!) and I don’t yet know enough about how LO uses Basic to convert it to a Sub. Can anyone provide some help on writing these two macros? What am I missing?