Hi everyone,
The following function calls appear to do the exact same thing, and I’m not sure if there are any advantages to using one or the other:
dtResult = oService.callFunction("com.sun.star.sheet.addin.Analysis.getEomonth", Array("2001-09-14", 6))
dtResult = oService.callFunction("EOMONTH", Array("2001-09-14", 6))
A few weeks ago, I needed to find a function to calculate the last day of a given month for use in a macro (N.B. not for use in a spreadsheet) and didn’t have much time to do a deep dive into how it worked, I just needed to get it working quickly.
The code snippet that I found here, which finally did the trick, was this:
Function CalculateEndOfMonth(ByVal date As String, ByVal months as Integer) As Long
mArgs = Array(date, months)
fca = createunoservice("com.sun.star.sheet.FunctionAccess")
lResult = fca.callFunction("com.sun.star.sheet.addin.Analysis.getEomonth", mArgs())
CalculateEndOfMonth = lResult
End Function
As you can see, this function uses "com.sun.star.sheet.addin.Analysis.getEomonth"
Now that I have some time to clean up my code, I’ve spent the last few days studying the documentation and forum discussions on here, on StackExchange, the OpenOffice forums and so on, but I still have no answer to the following question:
The official documentation, in the section “Calling Internal Calc functions in Basic”, seems to show that it is possible to call internal Calc functions using the syntax:
oService.callFunction("FUNCTIONNAME", Array(param1, param2, ...))
However, if you scroll down on the same page, in the section “UNO Service Names for Analysis Add-In Functions”, EOMONTH
is listed as an Analysis Add-In function with the corresponding UNO service name being com.sun.star.sheet.addin.Analysis.getEomonth
.
So, is EOMONTH
an internal function or an Analysis Add-In function? Which one should I be using in a Basic macro: EOMONTH
or com.sun.star.sheet.addin.Analysis.getEomonth
?
Thanks!