Its supposed to delete whats in cell A1. When I run it regularly it works just fine.
Here's the code:
Code: Select all
Function deletecellA1()
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "a1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Flags"
args2(0).Value = "SVDFN"
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args2())
end Function
=IF(C1=0;0;DELETECELLA1())
The problem is, when I type a "1" into cell C1 and enter it, when it gets to cell A1 to delete it, it tells me "Protected cells can not be modified" (with an ok button, and when you click that button it just goes to cell A2 and doesn't delete A1.).
"Protect document" is not being used. "Format cells">"Cell Protection" is not clicked.
Can anyone let me know why this is happening, and/or modify my code to make it work?
Thanks in advance!