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

Comment that I can not 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.

thanks @ajlittoz

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 @mikekaganski 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)
  oCell = oTab.getCellByPosition(oTab.columns.count-1, oTab.rows.count-1 )
  oVC.gotoRange(oCell, false) 
  oVC.goDown(1, false)  

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)