How to set BorderLineStyle for all the text tables in the odt (writer) file?

Hi all! I want to set BorderLineStyle by using macro for all the text tables in the odt (writer) file simultaneously, not by the cursor, please help me!!! :slight_smile:

Borders set for a TextTable generally are a complex mess of lots of single direct (“hard”) settings.

To make your text tables looking similar, you need to create a named TextTableTemplate (sometimes wrongly called a style), and to apply it to the tables probably created without the “style”. In specific if all the text tables in a document shall get the same so-called style, you can easily do this with a macro.

However, you cannot apply border settings, color settings, (whatever) independently. “One template, all the applicable settings.”

Please note: Assigning the TextTableTemplate of a table anew to that table will apply it completely and by that (in most cases) override additional direct settings. They aren’t that “hard”.

The Code (an example for):

Sub applyTableTemplateToAll(Optional pVersatile, Optional pTemplateName As String)
REM pVersatile is introduced to be prepared for cases where the Sub is called from 
REM a form button, a link, a toolbar icon...
If IsMissing(pTemplateName) Then pTemplateName = "mySpecialTableLaF"
doc = ThisComponent
tts = doc.TextTables
uTts = tts.Count - 1
For j = 0 To uTts
  j_tt = tts(j)
  j_tt.TableTemplateName = pTemplateName
Next j
End Sub

See also the attached example.
ask277832otherTextTableToy.odt