Thank, @JeJe, but unfortunately, I'm faced with a lot of troubles to create my first script.
1. I found some script what make function I want to do, firstly I need to catch any changing in worksheet. I found this function
Code: Select all
Option Explicit
' Declare a global variable to hold the listener
Private sheetChangeListener As Object
' This function initializes the sheet change listener
Sub InitializeSheetChangeListener()
' Check if the listener is already initialized
If Not IsNull(sheetChangeListener) Then Exit Sub ' prevent multiple listeners
' Create an instance of the listener class
Set sheetChangeListener = CreateObject("com.sun.star.sheet.SheetChangeListener")
' Get the current document
Dim document As Object
document = ThisComponent
' Get the active sheet
Dim sheet As Object
sheet = document.CurrentController.ActiveSheet
' Add the listener to the sheet
sheet.addSheetChangeListener(sheetChangeListener)
End Sub
' Implement the SheetChangeListener interface's "modified" method
Sub sheetChangeListener_modified(event As Object)
' Get the affected sheet
Dim affectedSheet As Object
affectedSheet = event.Sheet
' Unfortunately, there's no direct equivalent to VBA's "Target" range in OpenOffice.
' The following demonstrates how to get *all* changed cells since the last event.
' This is NOT the same as Target, as it doesn't give the cells directly involved in the current change.
Dim changedCells As Object
changedCells = affectedSheet.getChangedCells()
' Example: Print the address of each changed cell to the console.
Dim cell As Object
For Each cell In changedCells
Print cell.getCellAddress().AbsoluteName
Next cell
' Example: Check if cell A1 was among the changed cells
Dim a1 As Object
a1 = affectedSheet.getCellByPosition(0, 0) ' Column A, Row 1 (zero-based)
If NOT IsNull(changedCells) Then
Dim cellRange As Object
For Each cellRange in changedCells
If cellRange.getCellAddress().AbsoluteName = a1.getCellAddress().AbsoluteName Then
msgbox "Cell A1 was changed!"
Exit For ' Cell A1 found among changes
End If
next cellRange
End If
' IMPORTANT FOR PERFORMANCE: Clear the changed cells after processing
' Otherwise, they accumulate and checking change gets slow!
affectedSheet.clearChangedCells()
End Sub
' This Sub can be called from "Tools -> Macros -> Organize Macros -> OpenOffice Basic"
' to initialize the listener. It needs to be run only once per document session.
Sub StartListeningForSheetChanges()
InitializeSheetChangeListener
End Sub
Is this function looking good?
2. When I press button like PLAY in Toolbar I get this error "Error creating object"

- OpenOffice-12112024_114428_1.gif (30.1 KiB) Viewed 9818 times
3. Also I try to start this script as "Tools->Macros->Run Macro", in this case I'm faced with another troubles.

- OpenOffice-12112024_111205_1.gif (62.98 KiB) Viewed 9818 times
4. And finally, I try to set JRE environment in my computer, I have all of last version and and get trouble again. So, OpenOffice can accept my JRE environment - why?

- OpenOffice-12112024_113353_1.gif (67.48 KiB) Viewed 9818 times
(*) I used last version of Windows and last version of OpenOffice, registration on this forum is extremely painful and my current signature is wrong, there is no combobox/dropdown list to select OpenOffice version, any text value I try to set was wrong, except one, therefore sorry signature is incorrect, I already used all fresh version of OpenOffice and Windows.
Apache OpenOffice 4.1.13 for Microsoft and LibreOffice Community Version: 24.8.3.2 (X86_64) for Windows 11 Pro Version 10.0.22631 Build 22631