Macros OpenOffice作家。宏:替换选定的文本

Macros OpenOffice作家。宏:替换选定的文本,macros,replace,selection,openoffice.org,openoffice-writer,Macros,Replace,Selection,Openoffice.org,Openoffice Writer,我正在尝试创建一个宏,该宏将更改并替换OpenOffice Writer中当前选定的文本 到目前为止,我的宏如下所示: 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)

我正在尝试创建一个宏,该宏将更改并替换OpenOffice Writer中当前选定的文本

到目前为止,我的宏如下所示:

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
sub-myReplaceSelection
暗奥多克
暗卵细胞
调暗R为字符串
oDoc=该组件
oVC=oDoc.CurrentController.getViewCursor
如果Len(oVC.String)>0,则
R=进程选择(oVC.String)
'替换所选内容:
'我应该在这里调用哪个函数 好的,我明白了:

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
好的,我明白了:

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

或者更简单的:“oVC.setString(processSelection(oVC.String))”或者更简单的:“oVC.setString(processSelection(oVC.String))”