Macros/Calc/ba001/da

From The Document Foundation Wiki
< Macros‎ | Calc
Jump to navigation Jump to search
This page is a translated version of the page Macros/Calc/ba001 and the translation is 100% complete.

Template:Menu.Macros/da

Other languages:
English • ‎dansk • ‎español • ‎italiano


Beskrivelse

Kopiér indholdsceller fra et regneark til et andet. Kilderegnearket skal være åbent.

Basic-kode

 1Sub main()
 2DOC_NAME_SOURCE = "source.ods"
 3SHEET_NAME_SOURCE = "source"
 4CELL_NAME_SOURCE = "A1"
 5
 6    doc_source = get_doc(DOC_NAME_SOURCE)
 7    sheet_source = doc_source.Sheets.getByName(SHEET_NAME_SOURCE)
 8    cell_source = sheet_source.getCellRangeByName(CELL_NAME_SOURCE)
 9
10    doc = ThisComponent
11    sheet = doc.CurrentController.ActiveSheet
12    cell = sheet.getCellRangeByName(CELL_NAME_SOURCE)
13 
14    If cell_source.Type = 1 Then
15        cell.Value = cell_source.Value
16    ElseIf cell_source.Type = 2 Then
17        cell.String = cell_source.String
18    Else
19        cell.Formula = cell_source.Formula
20    End If
21End Sub
22
23Function get_doc(title)
24    docs = StarDesktop.getComponents()
25    enumeration = docs.createEnumeration()
26    Do While enumeration.hasMoreElements()
27        doc = enumeration.nextElement()
28        If doc.Title = title Then
29            Exit Do
30        End If
31    Loop
32    get_doc = doc
33End Function