I believe you should use modal dialog with an implementation of
com.sun.star.sheet.XRangeSelectionListener

Private sRangeSelection$,bRangeSelecting As Boolean
Sub test_RangeSelection()
oController = thisComponent.getCurrentController()
if oController.supportsService("com.sun.star.sheet.SpreadsheetView")then
oTgtRg = getRangeSelectionAddress(oController,sInitial:="",sTitle:="ClickTarget",bAutoClose:=True)
        If isUnoStruct(oTgtRg) then
msgbox("Sh:"& oTgtRg.Sheet &", SC:"& oTgtRg.StartColumn &", SR:"& oTgtRg.StartRow &", EC:"& oTgtRg.EndColumn &", ER:"& oTgtRg.EndRow)
        else
                msgbox "aborted or error"
        endif
endif
end sub
'calls: module-vars bRangeSelecting, sRangeSelection
'return a valid com.sun.star.table.CellRangeAddress from a user's range-selection (or Empty) Function getRangeSelectionAddress(oController,sInitial$,sTitle$,bAutoClose as Boolean)
On error goto returnEmpty
Dim oListener,aProps(2) As New com.sun.star.beans.PropertyValue
oListener = createUnoListener("RangeSelection_","com.sun.star.sheet.XRangeSelectionListener")
        oController.addRangeSelectionListener(oListener)
        aProps(0).Name = "InitialValue"
        aProps(0).Value = sInitial
        aProps(1).Name = "Title"
        aProps(1).Value = sTitle
        aProps(2).Name = "CloseOnMouseRelease"
        aProps(2).Value = bAutoClose
        With oController.getFrame
'this is required when calling from IDE or other frame in order to avoid endless loop
                .activate
                .getContainerWindow.toFront
        End With
        bRangeSelecting = True
        oController.startRangeSelection(aProps())
        while bRangeSelecting
                REM prevent CPU race
                wait 500
        Wend
        oController.removeRangeSelectionListener(oListener)
getRangeSelectionAddress = oController.getActiveSheet.getCellRangeByName(sRangeSelection).getRangeAddress
returnEmpty:
End Function
'calls: module-vars bRangeSelecting, sRangeSelection
Sub RangeSelection_done(oEv)
        sRangeSelection = oEv.RangeDescriptor
        bRangeSelecting = false
End Sub
'calls: module-vars bRangeSelecting, sRangeSelection
Sub RangeSelection_aborted(oEv)
        sRangeSelection = ""
        bRangeSelecting = false
End Sub
Sub RangeSelection_disposing(oEv)
End Sub

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to