Sub Exmpl1
Dim Data(4)
Data(0) = 15
Data(1) = 53
Data(2) = 3
Data(3) = -43
Data(4) = 5
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" )
MinValue = svc.callFunction("Min",Data())
Print MinValue
End Sub
Sub Exmpl2
Sheet = ThisComponent.Sheets.getByIndex(0)
oCellRange = Sheet.getCellRangeByName("A1:A10")
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" )
arg = Array(oCellRange)
MinValue = svc.callFunction("Min",arg)
Print MinValue
End Sub
Sub Exmpl3
Sheet = ThisComponent.Sheets.getByIndex(0)
oCellRange = Sheet.getCellRangeByName("A1:B10")
SearchValue = Sheet.getCellRangeByName("C1").getString()
Column = 2
Mode = 0
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" )
arg = Array(SearchValue, oCellRange, Column, Mode)
Value = svc.callFunction("VLOOKUP",arg)
Print Value
End Sub
FreqArray = array(oCellRange, oCellRange2)
oCellRange3.setData(svc.callFunction( "FREQUENCY", FreqArray ))
FJCC wrote:I think the MIN function can be used in a macro. Here are two examples.
- Code: Select all Expand viewCollapse view
Sub Exmpl2
Sheet = ThisComponent.Sheets.getByIndex(0)
oCellRange = Sheet.getCellRangeByName("A1:A10")
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" )
arg = Array(oCellRange)
MinValue = svc.callFunction("Min",arg)
Print MinValue
End Sub
FJCC wrote:Here is the original file.
Sub MaxValue
Sheet = ThisComponent.Sheets.getByIndex(0)
oCellRange = Sheet.getCellRangeByName("A16:A40")
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" )
arg = Array(oCellRange)
MaximumValue = svc.callFunction("Max",arg)
Print MaximumValue
End Sub
REM ***** BASIC *****
Sub Main
Dim svc As Object
Dim result
Dim oDate As Date
Dim oValueAdd
Dim oHolidayRange
Doc = ThisComponent 'refers to the whole file as object
Request = Doc.Sheets(0)
HolidayList = Doc.Sheets(1)
oDataRange = Request.getCellRangeByName("E1:E1000")
oHolidayRange = HolidayList.getCellRangeByName("A1:A1000")
oDate = Request.getCellRangeByName("B3").Value()
oValueAdd = Request.getCellRangeByName("B2")
'test = array(oDate,oValueAdd,oHolidayRange)
svc = createUnoService("com.sun.star.sheet.FunctionAccess")
result = svc.callFunction("WORKDAY",Array(oDate,oValueAdd,oHolidayRange))
'result = workday(test)
MsgBox(result)
End Sub
oSheet = ThisComponent.Sheets.getByName("Sheet3")
StartDate = oSheet.getCellrangeByName("A1").Value
DaysToAdd = oSheet.getCellrangeByName("B1").Value
oHolidays = oSheet.getCellrangeByName("C1:C2")
svc = createUnoService("com.sun.star.sheet.FunctionAccess")
result = svc.callFunction("WORKDAY",Array(StartDate,DaysToAdd,oHolidays))
print result
malazkd wrote:Hello Sir Villeroy, sorry but I am a beginner dev and I'm new in macro scripting.
I am developing a template that generates multiple requests to be uploaded in a system.
I need WORKDAY to compute due date for each request. Would you know how to implement WORKDAY in macro?.... Thanks.
Return to OpenOffice Basic, Python, BeanShell, JavaScript
Users browsing this forum: No registered users and 0 guests