Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM ***** BASIC *****
- Dim oDialog1 as object
- Sub StartDialog1()
- MySheet = ThisComponent.Sheets("Sheet1")
- basiclibraries.loadlibrary("Tools")
- oDialog1 = loadDialog("Standard","Dialog1")
- TB4 = oDialog1.Getcontrol("TextField4")
- oRange = UsedRange(MySheet)
- TB4.text = LastRow(oRange) + 1
- oDialog1.Execute()
- end sub
- Sub Simpan()
- Dim MySheet
- Dim Pesan as Integer
- REM melalui Active Sheet
- 'MySheet = thiscomponent.currentcontroller.getactivesheet()
- 'Melalui Sheet Name
- MySheet = ThisComponent.Sheets("Sheet1")
- TB1 = oDialog1.Getcontrol("TextField1")
- TB2 = oDialog1.Getcontrol("TextField2")
- TB3 = oDialog1.Getcontrol("TextField3")
- TB4 = oDialog1.Getcontrol("TextField4")
- 'msgbox oT1.text
- oRange = UsedRange(MySheet)
- TB4.text = LastRow(oRange) + 1
- Rem dengan RangeName, jika pake Cells xSheet.getCellByPosition(0,0)
- mysheet.getcellrangebyname("A" & TB4.text + 1).setString(TB4.text)
- mysheet.getcellrangebyname("B" & TB4.text + 1).setstring(TB1.text)
- mysheet.getcellrangebyname("C" & TB4.text + 1).setstring(TB2.text)
- mysheet.getcellrangebyname("D" & TB4.text + 1).setstring(TB3.text)
- Pesan = msgbox ("Berhasil disimpan", 64+0,"Pesan")
- tb1.text = ""
- tb2.text = ""
- tb3.text = ""
- end sub
- Sub Main
- mysheet = thiscomponent.currentcontroller.getactivesheet()
- cellA1 = mysheet.getcellrangebyname("A1")
- cellA1.setstring("Hello world")
- msgbox("Process completed")
- End Sub
- Function UsedRange(oSheet As Variant) As Variant
- Dim oCursor As Variant
- oCursor = oSheet.createCursor()
- oCursor.gotoEndOfUsedArea(False)
- oCursor.gotoStartOfUsedArea(True)
- UsedRange = oCursor
- End Function
- Function LastRow(oRange As Variant) As Long
- LastRow = oRange.getRangeAddress().EndRow
- End Function
- Sub Find
- MySheet = ThisComponent.Sheets("Sheet1")
- sAns = oDialog1.Getcontrol("TextField4").text
- If sAns = "" then End 'Blank entry or Cancel clicked.
- oDoc = ThisComponent
- oCell = oDoc.CurrentSelection 'Get active sheet index.
- index = oCell.CellAddress.Sheet
- oSheet = oDoc.getSheets.getByIndex(Index)'Get active sheet.
- FandR = oSheet.createSearchDescriptor 'Set up find and replace.
- FandR.setSearchString(sAns)
- 'FandR.SearchWords = true 'Entire cell must match.
- oCell = oSheet.findFirst(FandR)
- If not isNull(oCell) then
- oDialog1.Getcontrol("TextField1").text = mysheet.getcellrangebyname("B" & oCell.CellAddress.Row).string
- oDialog1.Getcontrol("TextField2").text = mysheet.getcellrangebyname("C" & oCell.CellAddress.Row).string
- oDialog1.Getcontrol("TextField3").text = mysheet.getcellrangebyname("D" & oCell.CellAddress.Row).string
- Else MsgBox "Not Found!"
- EndIf
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement