【问题标题】:OpenOffice Writer. Macro : replacing the selected textOpenOffice 作家。宏:替换选定的文本
【发布时间】:2023-12-29 05:05:02
【问题描述】:

我正在尝试创建一个宏来更改和替换 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

如何用我的字符串 'R' 替换当前选定的文本?

谢谢

【问题讨论】:

    标签: macros replace selection openoffice.org openoffice-writer


    【解决方案1】:

    好的,明白了:

    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))'
    最近更新 更多