2

OpenOfficeWriterで現在選択されているテキストを変更および置換するマクロを作成しようとしています。

これまでのところ、私のマクロは次のようになっています。

sub myReplaceSelection
Dim oDoc
Dim oVC
Dim R As String

oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
If Len(oVC.String) > 0 Then
   R = processSelection(oVC.String)
   'replace the selection:
   'which function should I call here ? <------------------
   '
EndIf
End sub

Function processSelection( s As String) As String
 '... ok , this part works fine
End Function

現在選択されているテキストを文字列'R'に置き換えるにはどうすればよいですか?

ありがとう

4

1 に答える 1

0

はい、わかった:

If Len(oVC.String) > 0 Then
  oVC = oDoc.CurrentController.getViewCursor
  If Len(oVC.String) > 0 Then
  Dim document   as object
  dim args1(0) as new com.sun.star.beans.PropertyValue
  args1(0).Name = "Text"
  args1(0).Value = processSelection(oVC.String)
  document = oDoc.CurrentController.Frame
  dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args1())
EndIf
于 2011-07-15T16:18:32.667 に答える