Styling cells with macro

247 views Asked by At

I'm new with OO Calc macros. With this code I can style cells on F13:F16 range

REM  *****  BASIC  *****
Option Explicit

Sub Main
oDoc = ThisComponent
osheets = odoc.getSheets()
osheet = osheets.getByIndex(0)
oCells = oSheet.getCellRangeByName("F13:F16")
NewBorder = oCells.BottomBorder
NewBorder.OuterLineWidth = 3
oCells.BottomBorder = NewBorder
End Sub

How can I edit this code so I can style cells I currently selected with mouse, instead of specifying them in the code?

1

There are 1 answers

1
Jim K On

Working with selected cells is a bit complex because either a single cell, a cell range, or multiple cell ranges may be selected.

Code that handles all of these possibilities is explained in the essential Andrew's Macro Document under section 6.5.1. Simple example processing selected cells.