So I got a big trouble with absolutely simple macro, which is 5 strings long in MSO, but absolutely ununderstandable in LO.
So, the situation. I have a CALC workbook with a lot of spreadsheets, and I need simple macro for copying values and formats from inactive spreadsheet (without changing window focus) to clipboard. Just to paste in some other workbooks as "values and formats". Nothing more.
ChatGPT offers me thousands scripts, and no one is workable at all.
I really cant understand, what is difficult to copy values to clipboard.
The only variant I made to work is
Code: Select all
Sub copy2clipboard()
Dim oDoc As Object
Dim oSheet As Object
Dim oSourceRange As Object
Dim oDispatcher As Object
oDoc = ThisComponent
oSheet = oDoc.Sheets.getByName("for_reports")
oSourceRange = oSheet.getCellRangeByName("B2:AS270")
'oDoc.CurrentController.Select(oSourceRange)
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDispatcher.executeDispatch(oDoc.CurrentController.Frame, ".uno:Copy", "", 0, Array())
End Sub
Please help to newbie, don't push me to "READ THE MANUAL", coz my English is not very well, just post the right macro code, and I will try to understand, I swear.