copyByName of sheet triggers modifyListener, runtime error
Posted: Tue Sep 10, 2019 5:01 pm
I have a sub that causes a runtime error when it tries to create a copy of an existing sheet.
This code has worked.
With the debugger (and prior to the error), I have found:
[*] newSheetName and newSheetNum look good before the call to copyByName
[*] I get many calls to "com.sun.star.util.XModifyListener" while copyByName is running (I put break points in the call back, "sub StepMode_modified(event as object)"
Here's the code that creates the listeners.
Here's the code up to the call that throws the error...
The error message says...
BASIC runtime error.
An exception occured.
Type: com.sun.star.uno.RuntimeException
Message: .
That's right: the message is a period.
What do you think?
What else would you like to know?
Thanks!
This code has worked.
With the debugger (and prior to the error), I have found:
[*] newSheetName and newSheetNum look good before the call to copyByName
[*] I get many calls to "com.sun.star.util.XModifyListener" while copyByName is running (I put break points in the call back, "sub StepMode_modified(event as object)"
Here's the code that creates the listeners.
Code: Select all
Sub StepModeListenerOn
Cycle_Steps = ThisComponent.Sheets.getByName("Cycle_Steps")
oRange = Cycle_Steps.getCellRangebyName("C6:c171")
oListener = createUnoListener("StepMode_", "com.sun.star.util.XModifyListener")
for steppe = 1 to 166
oCell = oRange.getCellByPosition(0,steppe-1)
oCell.addModifyListener(oListener)
next steppe
End Sub
Code: Select all
sub stepAlarmButton(eventer as object)
True = -1
False = 0
doc=ThisComponent
sheet=Doc.CurrentController.ActiveSheet
sheetName = sheet.spreadsheet.name
if sheetName = "SA_Template" then
dim pointName as string
SA_Template = ThisComponent.Sheets().getByName("SA_Template")
CellRange = SA_Template.getCellRangeByPosition(0,0,4,4)
Descript = CellRange.createSearchDescriptor()
Descript.SearchString = "Input"
Descript.SearchWords = False 'If true, the search will match only complete words
Cell = CellRange.findFirst(Descript)
pointNameCell = SA_Template.getCellByPosition(Cell.CellAddress.column+1, cell.CellAddress.row)
pointName = pointNameCell.string
newSheetName = "SA_" & pointName
if pointExists(pointName) then
sheetIs = sheetExists(newSheetName)
if not sheetIs then
newSheetNum = SA_Template.rangeAddress.sheet + 1
document = thiscomponent
document.getSheets().copyByName("SA_Template",newSheetName,newSheetNum)
BASIC runtime error.
An exception occured.
Type: com.sun.star.uno.RuntimeException
Message: .
That's right: the message is a period.
What do you think?
What else would you like to know?
Thanks!