stattool/_0Main.vb

57 lines
1.6 KiB
VB.net
Raw Normal View History

' _0Main: The main module for the statistics macros
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10
Option Explicit
' subMain: The main program
Sub subMain
BasicLibraries.loadLibrary "XrayTool"
Dim dStart As Date
dStart = Now
'MsgBox InStr (1, "abca", "ad")
'Xray ThisComponent.getSheets.getByIndex (0).getCellByPosition (0, 0)
'subTestCorrelation
MsgBox "Done. " & Format (Now - dStart, "mm:ss") & " elapsed."
End Sub
' fnQueryFormat: Returns the index of the number format, and creates the number format if required.
Function fnQueryFormat (oDoc As Object, sFormat As String) As Integer
Dim oFormats As Object, nIndex As Integer
Dim aLocale As New com.sun.star.lang.Locale
oFormats = oDoc.getNumberFormats
nIndex = oFormats.queryKey (sFormat, aLocale, True)
If nIndex = -1 Then
oFormats.addNew (sFormat, aLocale)
nIndex = oFormats.queryKey (sFormat, aLocale, True)
End If
fnQueryFormat = nIndex
End Function
' fnGetRangeName: Obtains the name of a spreadsheet cell range
Function fnGetRangeName (oRange As Object) As String
Dim nPos As Integer, sName As String
sName = oRange.getPropertyValue ("AbsoluteName")
nPos = InStr (sName, "$")
Do While nPos <> 0
sName = Left (sName, nPos - 1) & Right (sName, Len (sName) - nPos)
nPos = InStr (sName, "$")
Loop
fnGetRangeName = sName
End Function
' fnGetLocalRangeName: Obtains the name of a local spreadsheet cell range
Function fnGetLocalRangeName (oRange As Object) As String
Dim nPos As Integer, sName As String
sName = fnGetRangeName (oRange)
nPos = InStr (sName, ".")
If nPos <> 0 Then
sName = Right (sName, Len (sName) - nPos)
End If
fnGetLocalRangeName = sName
End Function