| View previous topic :: View next topic |
| Author |
Message |
mrexcel General User

Joined: 13 Apr 2012 Posts: 6
|
Posted: Sat Apr 14, 2012 4:08 am Post subject: [Solved]Check if a cell is changed |
|
|
Hello,everyone
I want to check if value of cell of sheet1!a2:z20 was changed.
| Code: | global Calc1 as Object
global oListner as Object
Sub AddListners
Calc1 = thisComponent.sheets(0).GetCellRangeByName("A2:Z20")
oListner = CreateUnoListener( "Sheet1_", "com.sun.star.util.XModifyListener" )
Calc1.AddModifyListener(oListner)
End Sub
Sub Sheet1_Modified(oEvent)
dim osels,ocell,osheet,osel
'on error resume next
oCell = thisComponent.currentSelection.CellAddress
oSheet = thisComponent.currentController.activeSheet
col=ocell.column
row=ocell.row
if col mod 4=0 then
osel= oSheet.getCellByPosition(col,row)
msgbox osel.string
end if
End Sub
Sub Sheet1_Disposing(oEvent)
End Sub
|
But I get an error:
"Property or method not found:CellAddress"
What causes this error? thanks for your help.
Last edited by mrexcel on Sat Apr 14, 2012 9:34 am; edited 1 time in total |
|
| Back to top |
|
 |
patel Power User

Joined: 14 Apr 2012 Posts: 54 Location: Italy
|
Posted: Sat Apr 14, 2012 5:51 am Post subject: |
|
|
I receive that error only when I delete a range of cells,
CellAddress is a cell method, not a range method |
|
| Back to top |
|
 |
mrexcel General User

Joined: 13 Apr 2012 Posts: 6
|
Posted: Sat Apr 14, 2012 7:30 am Post subject: |
|
|
Thanks for your reply.
I edited the code to check if the value of certain cell is "ok" or not,but it showed the messagebox for many times:
| Code: |
global Calc1 as Object
global oListner as Object
Sub AddListners
Calc1 = thisComponent.sheets(0).GetCellRangeByName("A2:Z20")
oListner = CreateUnoListener( "Sheet1_", "com.sun.star.util.XModifyListener" )
Calc1.AddModifyListener(oListner)
End Sub
Sub Sheet1_Modified(oEvent)
dim ocell,osheet,osel
on error resume next
oCell = thisComponent.currentSelection.CellAddress
oSheet = thisComponent.currentController.activeSheet
col=ocell.column
row=ocell.row
if col mod 4=0 then
OSEL= oSheet.getCellByPosition(col,row)
IF OSEL.string="ok" then
msgbox OSEL.string
end if
end if
End Sub
Sub Sheet1_Disposing(oEvent)
End Sub
|
Why this happened? How could I fix it? |
|
| Back to top |
|
 |
patel Power User

Joined: 14 Apr 2012 Posts: 54 Location: Italy
|
Posted: Sat Apr 14, 2012 8:14 am Post subject: |
|
|
I don't know, your macro works very well on my LibreOffice 3.3.4
try this
| Code: | global Calc1 as Object
global oListner as Object
Sub AddListners
Calc1 = thisComponent.sheets(0).GetCellRangeByName("A2:Z20")
oListner = CreateUnoListener( "Sheet1_", "com.sun.star.util.XModifyListener" )
Calc1.AddModifyListener(oListner)
End Sub
Sub Sheet1_Modified(oEvent)
dim ocell,osheet
on error resume next
oCell = thisComponent.currentSelection
IF oCell.string="ok" then
msgbox oCell.string
end if
End Sub
Sub Sheet1_Disposing(oEvent)
End Sub |
|
|
| Back to top |
|
 |
|