Cell B2 was made by this code:
REM ***** BASIC *****
Option Explicit
Sub MakeCellContentAndFormat
Dim oDoc As Object : oDoc = ThisComponent
Dim oSheet As object : oSheet = oDoc.CurrentController.ActiveSheet
Dim oCell As Object
Dim oRange As Object
Dim aThinBorder As New com.sun.star.table.BorderLine2
Dim oAnnotation As Object : oAnnotation = oSheet.GetAnnotations()
Dim oCellAddress As Object
Dim oColumns As object : oColumns = oSheet.getColumns() 'All columns of this sheet
oColumns.removeByIndex(0, 99)
MsgBox "Let's go !",,"Please press Enter"
oCell = oSheet.GetCellByPosition(1, 1)
oRange = oSheet.GetCellRangeByPosition(1, 1, 1, 1)
With oCell
.SetString("Cell B2")
oCellAddress = .CellAddress
oAnnotation.InsertNew(oCellAddress, "This is cell B2.")
.Annotation.IsVisible = True 'True = Show comment /False = No show
End With
With oRange
aThinBorder = .TopBorder2
aThinBorder.Color = RGB(255, 0, 0) 'Red
aThinBorder.InnerLineWidth = 0
aThinBorder.OuterLineWidth = 30
aThinBorder.LineDistance = 0
aThinBorder.LineStyle = 0
aThinBorder.LineWidth = 30
.LeftBorder2 = aThinBorder
End With
End Sub
If cell B2 was made manually, how can I check cell B2’s borders and get the border properties using macros?
And how can I check the comment of cell B2 using macros?
0031HowToGetCellFormatAndComment.ods (16.0 KB)
LibreOffice:
Version: 7.3.5.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 1:7.3.5-0ubuntu0.22.04.1
Calc: threaded
OS:
Ubuntu 22.04 LTS