Hi!
I'd like make a workbook. This WB load a text file, split lines to cells.
I'd like generate a dropdown list validation in every line last cell (the list items in other Sheet).
For example(this example my don't work):
oSheets = ThisComponent.getSheets()
oSheet1 = oSheets.getByName("Sheet1")
oCell = oSheet1.getCellRangeByName("M1")
oValidation = oCell.Validation
oValidation.setFormula1("Sheet1.A1:A3")
oCell.Validation = oValidation
Generating dropdown list with macro
Generating dropdown list with macro
LibreOffice 6.2.4 64bit on Debian testing & Win 10
Re: Generating dropdown list with macro
Just a tip:
Use a Template file that contains the predefined validations...
Use a Template file that contains the predefined validations...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Generating dropdown list with macro
This work for me in a empty sheet (I'll try to see if it works in my generated workbook):
Code: Select all
Sub DropDown
Dim FormulaStr1 as String
Dim FormulaStr2 as String
Sheet = ThisComponent.Sheets.getByIndex(0)
FormulaStr1 = "$Sheet2.$A$1:$A$7"
FormulaStr2 = "$Sheet2.$B$1:$B$3"
For i = 0 To 10
oCell = Sheet.getCellByPosition(0,i)
Validation = oCell.Validation
Validation.Type = com.sun.star.sheet.ValidationType.LIST
Validation.setOperator com.sun.star.Sheet.ConditionOperator.EQUAL
Validation.setFormula1(FormulaStr1)
oCell.Validation = Validation
oCell = Sheet.getCellByPosition(1,i)
Validation = oCell.Validation
Validation.Type = com.sun.star.sheet.ValidationType.LIST
Validation.setOperator com.sun.star.Sheet.ConditionOperator.EQUAL
Validation.setFormula1(FormulaStr2)
oCell.Validation = Validation
Next i
End Sub
LibreOffice 6.2.4 64bit on Debian testing & Win 10
Re: Generating dropdown list with macro
Where the macro was launched from?This WB load a text file, split lines to cells.
I'd like generate a dropdown list validation in every line last cell (the list items in other Sheet).
For example(this example my don't work):
oSheets = ThisComponent.getSheets()
Maybe it was launched from the text file. Then the "Thiscomponent" means: "the actual text document".
Please upload your ODF type sample files here.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.