2016-11-09 5 views
0

ODTドキュメントに名前付きテーブルがあり、すべてのコンテンツを含む最後の行を新しい行に複製してからこの複製の値を置き換えます。BASICを使用してLibreOffice内のテーブルの最終行を重複します

私はDOCXのために、すでにワード/ 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) 

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

答えて

1

最初にView Cursorを移動して行全体を選択します。その後、ディスパッチャを使用して新しい行にコピー&ペーストします。このようなもの:

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()) 
関連する問題