Running a macro when value of cell changes

Creating a macro - Writing a Script - Using the API

Running a macro when value of cell changes

Postby DUNDUMON » Mon Nov 28, 2016 12:57 pm

Whats the equivalent API for

Private Sub Worksheet_Change(ByVal Target As Range) in Open Office.
Open Office 4.1.3
DUNDUMON
 
Posts: 8
Joined: Fri Nov 25, 2016 11:31 am

Re: Running a macro when value of cell changes

Postby RoryOF » Mon Nov 28, 2016 1:40 pm

Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29909
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Running a macro when value of cell changes

Postby einstein » Mon Nov 28, 2016 8:20 pm

It would be to see a specific case.
Here a possible example (without using "listeners").
For range A2:A30
Code: Select all   Expand viewCollapse view
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
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

Postby karolus » Tue Nov 29, 2016 4:57 pm

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

Code: Select all   Expand viewCollapse view
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 - 5.1 … 5.3.2.2 on Linux Mint17
User avatar
karolus
Volunteer
 
Posts: 852
Joined: Sat Jul 02, 2011 9:47 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests