Macros/Calc/ba001/nl
TDF LibreOffice Document Liberation Project Blogs gemeenschap Weblate Nextcloud Redmine Ask LibreOffice Doneren
Beschrijving
Kopieer de inhoud van de cel van de spreadsheet naar een andere. De bron van de spreadsheet moet open zijn.
Basic code
Sub main()
DOC_NAME_SOURCE = "source.ods"
SHEET_NAME_SOURCE = "source"
CELL_NAME_SOURCE = "A1"
doc_source = get_doc(DOC_NAME_SOURCE)
sheet_source = doc_source.Sheets.getByName(SHEET_NAME_SOURCE)
cell_source = sheet_source.getCellRangeByName(CELL_NAME_SOURCE)
doc = ThisComponent
sheet = doc.CurrentController.ActiveSheet
cell = sheet.getCellRangeByName(CELL_NAME_SOURCE)
If cell_source.Type = 1 Then
cell.Value = cell_source.Value
ElseIf cell_source.Type = 2 Then
cell.String = cell_source.String
Else
cell.Formula = cell_source.Formula
End If
End Sub
Function get_doc(title)
docs = StarDesktop.getComponents()
enumeration = docs.createEnumeration()
Do While enumeration.hasMoreElements()
doc = enumeration.nextElement()
If doc.Title = title Then
Exit Do
End If
Loop
get_doc = doc
End Function