0

ODT ドキュメントに名前付きテーブルがあり、すべてのコンテンツを含む最後の行を新しい行 (上記) に複製し、この複製の一部の値を置き換えたいと考えています。

私はすでにDOCX用にWord/VBAでこれを行っています:

Dim tbl As Table
Dim rowNew As Row

Set tbl = ActiveDocument.Tables(1)
Set rowNew = tbl.Rows.Add(tbl.Rows(tbl.Rows.Count))
rowNew.Range.FormattedText = tbl.Rows(tbl.Rows.Count).Range.FormattedText
'~~~> This is required as the above code inserts a blank row in between
tbl.Rows(tbl.Rows.Count - 1).Delete
rowNew.Select
Selection.Find.Execute FindText:="xx*", ReplaceWith:="bar", MatchWildcards:=True
Selection.Collapse

これはLibreOfficeでも可能ですか? これまでのところ、私は持っています:

DIM tbl As Variant
DIM row As Variant
tbl =  ThisComponent.getTextTables().getByIndex(0)
row = tbl.getRows().getByIndex(tbl.getRows().getCount()-1)

全体を選択して複製し、この新しい行で検索と置換を実行するにはどうすればよいですか? ヒント: 行には、サブテーブルなどの他のオブジェクトが含まれる場合があります。

4

1 に答える 1

1

まず、ビュー カーソルを行全体に移動して、行全体を選択します。次に、ディスパッチャを使用して、コピーして新しい行に貼り付けます。このようなもの:

oVC.goRight(3, True)  'Extend the selection.
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:InsertRowsAfter", "", 0, Array())
oVC.goDown(1, False)  'Move to the new row.
oVC.goLeft(2, False)  'Move to the first column.
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
于 2016-11-11T06:31:26.580 に答える