Last active
October 5, 2021 04:22
-
-
Save Kennyl/317c376e17bd78af3905de2d8c375bea to your computer and use it in GitHub Desktop.
LibreOffice Calc Macro Basic Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Basic Script for Libre Office Calc , Demo AutoFill | |
Sub AutoFill | |
Sheets = ThisComponent.getSheets() | |
oSheet = Sheets.getByName("MemberList") | |
oRange = oSheet.getCellRangeByName("A2:A6") ' A4:A6 has no data | |
oRange.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM,1) | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Basic Script for Libre Office Calc , Demo Copy and Paste in Macro | |
Sub CopyExample | |
Sheets = ThisComponent.Sheets | |
SheetCopy = Sheets.getByName("MemberList") 'From | |
CopyRange = SheetCopy.getCellRangeByName("A1:M250") | |
CopyAddress = CopyRange.RangeAddress | |
SheetPaste = Sheets.getByName("Sheet5") 'To | |
PasteCell = SheetPaste.getCellRangeByName("B5") | |
PasteAddress = PasteCell.CellAddress | |
SheetCopy.CopyRange(PasteAddress, CopyAddress) | |
MsgBox "CopyAddress :" & Chr(13) &_ | |
" " & CopyRange.AbsoluteName &_ | |
Chr(13) & Chr(13) &_ | |
"PasteAddress :" & Chr(13) &_ | |
" " & PasteCell.AbsoluteName | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Basic Script for Libre Office Calc , Demo Search | |
Sub SearchExample | |
Sheets = ThisComponent.getSheets() | |
oSheet = Sheets.getByName("MemberList") | |
oDescriptor = oSheet.createSearchDescriptor() | |
With oDescriptor | |
.SearchString = Sheets.getByName("Main").getCellRangeByName("B3:B3").getString() | |
.SearchWords = true 'The attributes default to False | |
.SearchCaseSensitive = False 'So setting one to False is redundant | |
End With | |
' cell = sheet.getCellRangeByName("A1:C10").findFirst(oDescriptor) | |
cell = oSheet.findFirst(oDescriptor) ' whole sheet | |
If not isNull(cell) then | |
MsgBox "Row = " & cell.CellAddress.Row & Chr(13) &_ | |
"Column = " & cell.CellAddress.Column | |
Else MsgBox "Not Found!" | |
''' | |
EndIf | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment