Hi!
Anyone can suggest how to set data validity for cell in OO Calc (via OOoBasic Macro, of course, not manually)?
Data validity option looks like this:
1 - Ins. P-P
2 - Ins. S-S
3 - Ins. P-S
4 - None
and format of the cell (like #,##0.00 + bold/font size 9 for example)?
Thanks in advance for any suggestion(s)
Set Data->Validity in OOo Calc Macro
-
mauriciobaeza
- Posts: 56
- Joined: Thu Apr 22, 2010 5:03 am
Re: Set Data->Validity in OOo Calc Macro
Hi...
The following macro sets the validation you want for the cell A1, the second macro formats the current selection.
Best Regards
The following macro sets the validation you want for the cell A1, the second macro formats the current selection.
Code: Select all
Option Explicit
Sub Validate()
Dim oCel As Object
Dim oValidation As Object
oCel = ThisComponent.getCurrentController.getActiveSheet.getCellRangeByName( "A1" )
oValidation = oCel.getPropertyValue("Validation")
With oValidation
.Type = com.sun.star.sheet.ValidationType.LIST
.setFormula1 ( "'Ins. P-P';'Ins. S-S';'Ins. P-S';'NONE'" )
.ShowList = com.sun.star.sheet.TableValidationVisibility.SORTEDASCENDING
.ShowErrorMessage = True
.ErrorAlertStyle = com.sun.star.sheet.ValidationAlertStyle.STOP
.ErrorTitle = "Erroneous data"
.ErrorMessage = "The value entered is not valid"
End With
oCel.setPropertyValue("Validation", oValidation)
End Sub
Sub FormatCell()
Dim oSel As Object
oSel = ThisComponent.getCurrentSelection()
With oSel
'Font Name
.CharFontName = "Liberation Sans"
'Size font
.CharHeight = 20
'Bold
.CharWeight = 150
'Italic
.CharPosture = 2
'Underline
.CharUnderline = 1
End With
End Sub______________________________________________
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum