How to create table border and line style Using createUnoService("com.sun.star.table.CellProperties") in LibreOffice Calc Macro?

I Want to Create Table Border

Can any one help me how to form the Macro Code to create Table border and Line Style Using
createUnoService(“com.sun.star.table.CellProperties”) ,
instead of CreateUnoStruct(“com.sun.star.table.BorderLineStyle”) and CreateUnoStruct(“com.sun.star.table.BorderLine”) or
CreateUnoStruct(“com.sun.star.table.BorderLine2”) ?

See here

Hi @karolus,

I want the code Using createUnoService(“com.sun.star.table.CellProperties”) and Not the code Using
createUnoService(“com.sun.star.frame.DispatchHelper”)

Scroll down!

We may want tis and that. Sometimes we can’t get it.
Well, I suppose you tried something like

whatiWouldLike = createUNOService("com.sun.star.table.CellProperties”)

in a Basic Sub.
What did you get? If I try, I get a Null object. That’s what I expected.
Same with

foobar = CreateUnoStruct("com.sun.star.table.BorderLineStyle")

What did you expect for what reasons?

Let’s try a reasonable example:

Sub doSomethingReasonable()
testRange        = ThisComponent.Sheets(0).getCellRangeByName("C4:H11")
Dim tableBorder2 As New com.sun.star.table.TableBorder2
Dim edgeBorder2  As New com.sun.star.table.BorderLine2
Dim innerBorder2 As New com.sun.star.table.BorderLine2
With edgeBorder2
 .Color          = RGB(016, 000, 240)
 .LineWidth      = 90
 .LineStyle      = 7
End With
With innerBorder2
 .Color          = RGB(255, 016, 000)
 .LineWidth      = 30
 .LineStyle      = 0
End With
With tableBorder2
 .RightLine             = edgeBorder2
 .IsRightLineValid      = True
 .LeftLine              = edgeBorder2
 .IsLeftLineValid       = True
 .HorizontalLine        = innerBorder2
 .IsHorizontalLineValid = True
innerBorder2.Color     = RGB(000, 255, 111) REM "On the fly."
innerBorder2.LineWidth = 44                 REM again
 .VerticalLine          = innerBorder2
 .IsVerticalLineValid   = True
End With
testRange.TableBorder2  = tableBorder2
End Sub
2 Likes