Button in Macro to Print a Sheet

Good Night…

I need a macro code to associate a button in order to Print a sheet, in Libreoffice Calc…

Can someone help me ?

Thanks a lot!

.

Sub PrintDoc
            
Dim Document As object
    
Dim Dispatcher As Object
    
Document = ThisComponent.CurrentController.Frame
    
Dispatcher = createUNOService("com.sun.star.frame.DispatchHelper")
    
Dispatcher.executeDispatch(Document,".uno:Print", "", 0, Array())
    
End sub

On the spreadsheet Menu: View…ToolBars…FormControl. Create the button. Open the Button. In Design mode find the Events menu to enable connection with the above Macros. This should be in “Mouse button pressed” list to enable its action.
Hope this helps.

Edit to put the code in a code block.

Thank You so much!!!

It worked …