OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Solved]Check if a cell is changed

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
mrexcel
General User
General User


Joined: 13 Apr 2012
Posts: 6

PostPosted: Sat Apr 14, 2012 4:08 am    Post subject: [Solved]Check if a cell is changed Reply with quote

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
View user's profile Send private message
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Sat Apr 14, 2012 5:51 am    Post subject: Reply with quote

I receive that error only when I delete a range of cells,
CellAddress is a cell method, not a range method
Back to top
View user's profile Send private message
mrexcel
General User
General User


Joined: 13 Apr 2012
Posts: 6

PostPosted: Sat Apr 14, 2012 7:30 am    Post subject: Reply with quote

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
View user's profile Send private message
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Sat Apr 14, 2012 8:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group