Running a macro when value of cell changes

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
DUNDUMON
Posts: 8
Joined: Fri Nov 25, 2016 11:31 am

Running a macro when value of cell changes

Post by DUNDUMON »

Whats the equivalent API for

Private Sub Worksheet_Change(ByVal Target As Range) in Open Office.
Open Office 4.1.3
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Running a macro when value of cell changes

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
einstein
Posts: 47
Joined: Sat Nov 05, 2016 1:45 am
Location: State of Mexico, México.

Re: Running a macro when value of cell changes

Post by einstein »

It would be to see a specific case.
Here a possible example (without using "listeners").
For range A2:A30

Code: Select all

Sub Worksheet_Change
   rAdd = ThisComponent.getCurrentSelection.rangeAddress
   If rAdd.startColumn = 0 Then
   If rAdd.startRow < 30 And rAdd.endRow > 0 Then
      MsgBox "Your Macro"
   End If
   End If
End Sub
Set it to the event of the sheet (Right click on the spreadsheet tab <> Sheet Events <> Content Changed ...)
lo 5.1.6.2 | aoo 4.1.3 | win 7/10
All I know is that I know nothing
User avatar
karolus
Volunteer
Posts: 1160
Joined: Sat Jul 02, 2011 9:47 am

Re: Running a macro when value of cell changes

Post by karolus »

Here is an example you should prefer for use on Sheet-Event →→ Content changed

Code: Select all

Sub Content_change( changed_cell )
    sheet = changed_cell.Spreadsheet
    observed_range = sheet.getCellRangeByName("A2:A30")
    if observed_range.queryIntersection( changed_cell.RangeAddress ).Count >0 then '# inside range of Interest#'
         msgbox( changed_cell.AbsoluteName)
    end if
end Sub
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Post Reply