Sub SetBorderColor
Dim oBordeLinea As New com.sun.star.table.BorderLine
With oBordeLinea
.Color = RGB(255,0,0)
.InnerLineWidth = 500
.OuterLineWidth = 50
.LineDistance = 20
End With
NroCelda = "A" & CStr(1) & ":" & "J" & CStr(1)
oRango = ThisComponent.Sheets.getByName("Sheet1").getCellRangeByName(NroCelda)
msgbox NroCelda
With oRango
.TopBorder = oBordeLinea 'Superior
.BottomBorder = oBordeLinea 'Inferior
.LeftBorder = oBordeLinea 'Izquierdo
.RightBorder = oBordeLinea 'Derecho
End With
End Sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
oSheet = ThisCOmponent.Sheets.getByName("Sheet2")
oCelda = oSheet.getCellrangeByName("A15")
Dim oBordeLinea As New com.sun.star.table.BorderLine
With oBordeLinea
.Color = RGB(255,0,0)
.InnerLineWidth = 50 'Changed from 500. The Linewidth is in steps of 0.01 mm, so 500 is very large
.OuterLineWidth = 50
.LineDistance = 20
End With
NroCelda = "A" & oCelda.value & ":" & "P" & oCelda.value 'This works, but oCelda.value is a number not a string.
oRango = ThisComponent.Sheets.getByName("Sheet2").getCellRangeByName(NroCelda)
msgbox NroCelda
With oRango
.TopBorder = oBordeLinea 'Superior Changed from TopBorder.oBordeLinea
.BottomBorder = oBordeLinea 'Inferior
.LeftBorder = oBordeLinea 'Izquierdo
.RightBorder = oBordeLinea 'Derecho
End With
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
it's an .ods. FJCC, your example starts with a red bordered row, but when I push the button, red lines go off and they never come again.
I'm new at this forum, and I couldn't find a way to send to you my sub. Either way, it appears that my problem it's not in my code, cos' this file you sent me doesn't work for me, but it does for you, tough. (sorry about my En.)
It seems you have the problem on the specifc office version, which version are you using?
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
I see, you are using LibreOffice, so border problem on spreadsheets is still there.
I tried FJCC's document on LibreOffice 3.5.1, it does not work at all.
And I do not know about build 402 but the document works on most recent version of Apache OpenOffice (AOO340m1 Rev1299571).
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
I remember a similar situation about 1 year back, I think I was using OOo 3.1.1 at that time. And I thought I did everything in the right way, but my borders did not show up. Until I gave it a try and did explicitly set the property .IsXXXXLineValid to True.
Maybe it is also related with the UNO structure "com.sun.star.table.TableBorder" that I am using and that isn't used in any of the other code samples that are posted here:
Sub DrawBorder4Range( oRange As Object )
Dim aTableBorder As New com.sun.star.table.TableBorder
Dim aBorder
aBorder = createUnoStruct("com.sun.star.table.BorderLine")
With aBorder
.Color = RGB(255,0,0) ' 16711680 light red, 0 for black
.OuterLineWidth = 50
.InnerLineWidth = 50
.LineDistance = 20
End With
With aTableBorder
.TopLine = aBorder
.RightLine = aBorder
.BottomLine = aBorder
.LeftLine = aBorder
.Distance = 0
.IsTopLineValid = True
.IsRightLineValid = True
.IsBottomLineValid = True
.IsLeftLineValid = True
End With
oRange.TableBorder = aTableBorder
End Sub
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
I've adapted my code, acording to your suggestions, but it still doesn't work. It says that "IsXXXXLineValid to True" (all the lines of this kind) are not recognized..
But you are aware of the difference in my code to the other suggestions and to your approach?!
In my code (which is surely not superior, but only happened to work for me) the last With statement is applied to a TableBorder UNO-Structure, not to a range object as in all the other cases.
Actually the range comes only into account in the very last line where its tableBorder property is set to the TableBorder UNO structure that I have just prepared before.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Out of curiosity I have tested my code with ApacheOpenOffice 3.4.0 (340m1-Build:9586) with a sub that contains only the following single line: Call DrawBorder4Range(ThisComponent.getCurrentSelection()).
And I see the expected behaviour: If I comment out the line .IsRightLineValid = True, note the line is only skipped, I don't set the property to False, then the red line of the right sight of the selected region doesn't show up. If all 4 isValid properties are set to True I got the full red rectangle.
For me this seems very much like there is something wrong in your user profile. Create another (non-privileged) user and start OpenOffice for this user to have it running with a fresh and innocent user profile.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
This is based on a script which I have been using for years to set a bottom border only. I have edited the lines defining the colour to rgb because I don't remember where to get the number I use (which is 128 = black).