05/12/05 21:35:17
セルの選択のしかたで返すオブジェクトが違うとは思わなかった。
エラーがあったら各自で修正して。
sub AddValueToSelectedCells(modify)
dim oCellRange, oRangeArry, oCellEnum, oCell, row, col
oCellRange = ThisComponent.getCurrentController().getSelection()
select case oCellRange.getImplementationName()
case "ScCellObj" '単一セル選択
oCellRange.Value = oCellRange.Value + modify
case "ScCellRangeObj" '矩形選択
oRangeArry = oCellRange.getRangeAddress()
for row = 0 to oRangeArry.EndRow - oRangeArry.StartRow
for col = 0 to oRangeArry.EndColumn - oRangeArry.StartColumn
oCell = oCellRange.getCellByPosition(col, row)
oCell.Value = oCell.Value + modify
next col
next row
case "ScCellRangesObj" '不定形選択
oRangeArry = oCellRange.getCells()
oCellEnum = oRangeArry.createEnumeration()
do while oCellEnum.hasMoreElements()
oCell = oCellEnum.nextElement()
oCell.Value = oCell.Value + modify
loop
end select
end sub