[SOLVED]Hi:
Wrote the following to test zeroing out data in a group of cells.
Sub zeroOnButtonPress
xKtr = 0
yKtr = 0
oSheet = ThisComponent.getSheets().getByName("Sheet1")
for xKtr = 2 to 3
for yKtr = 6 to 9
oCell = oSheet.getCellByPosition(xKtr,yKtr)
oCell.value = 0
next
next
End Sub
During testing though, I noticed that if I started editing a cell - ie typing "asdf" into the cell, and then clicked on the button to run the macro, all of the cell values change EXCEPT the cell I was in edit mode with.
How do you force the cell out of edit mode prior to changing the data?
Thanks,
Brody
[Solved] Cell contents via Basic while cell is in input mode
[Solved] Cell contents via Basic while cell is in input mode
Last edited by brody on Fri Dec 15, 2017 5:50 pm, edited 2 times in total.
OpenOffice 4.1.4 on Windows 10
Re: Updating cell contents via Basic while cell is in input
Here is an ugly hack that seems to work.
Code: Select all
Sub zeroOnButtonPress
oCntrl = ThisComponent.CurrentController
xKtr = 0
yKtr = 0
oSheet = ThisComponent.getSheets().getByName("Sheet1")
oCell = oSheet.getCellByPosition(0,0)
oCntrl.select(oCell)
for xKtr = 2 to 3
for yKtr = 6 to 9
oCell = oSheet.getCellByPosition(xKtr,yKtr)
oCell.value = 0
next
next
End Sub
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Updating cell contents via Basic while cell is in input
Oh clever. Selecting a indifferent cell rather than DE-selecting the current one. I like this. Thank you so much!
OpenOffice 4.1.4 on Windows 10