Hi All,
Plain English Goal: I want to enter a value into A2, when a value is entered it triggers an input box, the value of the inputted data goes into B2, depending on B2s value, another input box comes up.
Achieved: I’ve gotten A2 change to trigger input box which then goes into B2. See code below +++
Fail: Cannot get a second instance going, everything I try triggers loops, crashes, or other fuggly things. I’m guessing that I have to remove the one instance of the listener and then get another one established for B2.
Thoughts appreciated.
+++++
Sub addlistener
dim document as object
oDoc = StarDesktop.CurrentComponent
oSheets = oDoc.getSheets()
oSheet = oSheets.getByName("Sheet1") ' Of cause you can specify any other sheet
oCell = oSheet.getCellRangeByName("A2") 'Of cause you can specify any other cell
oListener = CreateUnoListener( "OOO_", "com.sun.star.chart.XChartDataChangeEventListener" )
oCell.addChartDataChangeEventListener(oListener)
End Sub
Sub OOO_chartDataChanged
rem This is the body/code of the Macro called "Testcell"
oDoc = StarDesktop.CurrentComponent
oSheets = oDoc.getSheets()
oSheet = oSheets.getByName("Sheet1")
oCell = oSheet.getCellRangeByName("A2")
rem oCell = oView.getSelection() ' "un-rem" this line to test the cell selected by ' cursor rather then cell E28 - "rem" previous line
nValue = oCell.getValue()
nString = oCell.getString()
nFormula = oCell.getFormula()
Dim sFM as String
sFM = InputBox ("Is this a felony or misdo? (F/M)")
sFMCell = oSheet.getCellRangeByName("B2")
sFMCell.string = sFM
end sub