Macros/Calc/ba001/da
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Beskrivelse
Kopiér indholdsceller fra et regneark til et andet. Kilderegnearket skal være åbent.
Basic-kode
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