2011年6月3日金曜日

OpenOffice > Basic > 選択された文字列を取得

'文字列を取得する
'Calcの場合は選択されているセルの文字列
'Writerの場合は選択されている文字列
'Calcのセル内で選択されている文字のみを抽出する機能はない
Function GetSelectedText

controller = ThisComponent.CurrentController
selection = controller.getSelection()
iName = selection.ImplementationName
If iName="SwXTextRanges" Then
GetSelectedText = selection.getbyindex(0).String
ElseIf iName="ScCellObj" Then
GetSelectedText = selection.String
Else
GetSelectedText = ""
End If

End Function

0 件のコメント:

コメントを投稿