# [Solved] writer macro for extending selection from table to paragraph before and after table

Comment that I can not delete

edit retag close merge delete

@torreone: adding "Solved" in the title is not the right way to mark the question as "solved" because it will still be counted as unanswered by the site engine.

For a much better referencing in the site, answer your own question by cutting "Having found …" up to the end and pasting it in your answer. I used "cutting" instead of "copying", meaning you should edit your question so that it looks like a question (explaining why you ask a new one) which now receives an acceptable answer.

To be really useful your question should include a link to 223599/writer-macro-for-extending-selection-from-table-to-paragraph-before-and-after-table.

A much better solution would be to reopen question #223599 to add your own answer. Your karma is high enough to allow you to do that and delete this one afterwards.

( 2021-01-28 15:06:13 +0200 )edit

thanks @ajlittoz

( 2021-01-28 22:52:51 +0200 )edit

Sort by » oldest newest most voted

In question 223599/writer-macro-for-extending-selection-from-table-to-paragraph-before-and-after-table I posed the problem described by the title that @Mike Kaganski had given a solution to Subsequently, after having closed the question, I had found an alternative solution that I propose here since I cannot reopen the closed discussion (it takes more than 200 karma to do this)

sub selectTable1(sTable)

Dim oD, oTab, oCell, oTC1, oVC
oD = ThisComponent
oTab = oD.getTextTables().getByName(sTable)
oVC = oD.getCurrentController().getViewCursor()

oCell = oTab.getCellByPosition(0, 0)
oVC.gotoRange(oCell, false)
oVC.goup(1, false)
oTC1=oVC.text.createTextCursorByRange(oVC)
oTC1.gotoEndOfParagraph(false)

oCell = oTab.getCellByPosition(oTab.columns.count-1, oTab.rows.count-1 )
oVC.gotoRange(oCell, false)
oVC.goDown(1, false)
oTC1.gotoRange(oVC,true)

oD.getCurrentController().select(oTC1)

End Sub


Thanks to @ajlittoz per the explaining the correct procedure to me.

I hope it is correct now.

(yes, I just edited the link to make it nicer)

more