Print macro not working in elementary os

Hi All
I have a macro in calc to print the current sheet. It was working in Windows system. But the same macro is not working in elementary OS. Its not throwing any error also. Please help me in this

Thanks

Originally added as answer - 2020-11-29

Sorry guys
Here is the macro I am using

Sub printreport(sSheetName1 as String)

 Dim args2(2) as New com.sun.star.beans.PropertyValue
 Dim dispatcher as Object

 reportSheet = oDoc.Sheets.getByName(sSheetName1)
 reportSheet.IsVisible = TRUE

 ThisComponent.CurrentController.ActiveSheet = reportSheet
 oReport = ThisComponent.CurrentController.Frame

 args2(0).Name = "Copies"
 args2(0).Value = 1
 args2(1).Name = "Selection"
 args2(1).Value = true
 args2(2).Name = "Collate"
 args2(2).Value = false

 Msgbox("Printing")
 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
 dispatcher.executeDispatch(oReport, ".uno:Print", "", 0, args2()) 

 Msgbox("Please click Ok only after Page Printed")
 reportSheet.IsVisible = False
 
End Sub

I haven’t yet connected to any printer yet, but in Windows when this macro is called it is opening the Print dialog, and in elementary OS Print dialog is not opening and not throwing any error message.

Thanks all

[Edit - Opaque] Moved from an answer to details of question - Deleted answer, which did not answer this question.

How should anyone be able to help you without knowing how your macro looks like, what error messages you might get and whether printing (to which printer type/model?) works at all without using a macro? We simply don’t see what you see. The way your question is right now, we need a fortune teller.

“we need a fortune teller.” :slight_smile:

@tmak99


Please do **not** use *Add Answer* but **[edit](https://ask.libreoffice.org/t/print-macro-not-working-in-elementary-os/59040)** your original question to enhance the details of your question (answers are reserved for solutions to a problem on this Q&A site). For that reason your answer has been deleted after having moved its content to question deatils.

reportSheet = oDoc.Sheets.getByName(sSheetName1)

Can’t believe that this macro works on Windows. oDoc is not defined here.