This is a short BASIC Calc macro intended to build a simple spreadsheet with multiple “conditional formatting” cells. It runs cleanly but does not create the conditional formats. Clearly I am misunderstanding something important. A pointer would be appreciated.
Sub Main oDoc = ThisComponent oDoc.sheets(0).getCellByPosition(0, 0).setFormula("5") oDoc.sheets(0).getCellByPosition(1, 0).setFormula("Format me") oDoc.sheets(0).getCellByPosition(1, 0).ConditionalFormat.addNew( Array( _ MakePropertyValue( "Operator", com.sun.star.sheet.ConditionOperator.FORMULA ),_ MakePropertyValue( "Formula1", "A1=5" ), _ MakePropertyValue( "StyleName", "Heading" ) ) oDoc.sheets(0).getCellByPosition(0, 1).setFormula("5") oDoc.sheets(0).getCellByPosition(1, 1).setFormula("Format me") oDoc.sheets(0).getCellByPosition(1, 1).ConditionalFormat.addNew( Array( _ MakePropertyValue( "Operator", com.sun.star.sheet.ConditionOperator.FORMULA ), _ MakePropertyValue( "Formula1", "A2=5" ), _ MakePropertyValue( "StyleName", "Result" ) ) End Sub Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function