I know how to select a cell range in OOo Basic, e.g.:
Code: Select all
oRange = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("A3:F3")
If so, how to do this.
All help is welcome. Thanks in advance.
Code: Select all
oRange = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("A3:F3")
Code: Select all
a() = Array("A1:B5", "B2:C6", "C3:D7")
oBasket = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
oView = ThisComponent.getCurrentController()
oSheet = oView.getActiveSheet()
for each n in a()
rg = oSheet.getCellRangeByName(n)
addr = rg.getRangeAddress()
oBasket.addRangeAddress(addr, False)
next
oView.select(oBasket)
Code: Select all
a() = Array("A1:B5", "B2:C6", "C3:D7")
REM convert to semicolon separated list
s = join(a(), ";")
aRanges() = ThisComponent.Sheets.getCellRangesByName(s)
Code: Select all
oBasket = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
for each rg in aRanges()
oBasket.addRangeAddress(rg.getRangeAddress(), False)
next
Code: Select all
a() = Array("A1:B5", "B2:C6", "C3:D7")
b() = Array("A1", "B2", "C3")
c(0) = "A1"
c(1) = "B2"
c(2) = "C3"
Code: Select all
print b(1), typename(b(1)), vartype(b(1))
print c(1), typename(c(1)), vartype(c(1))
Code: Select all
Dim c as Integer
c(0) = x
BASIC was created for beginners. There are a lot of interpreters around... including cross platform ones. Plus VBA and Openoffice - the world's two main office suites.IMHO, Basic is not the right language for beginners because it is a dead end and because it is strictly limited to certain environments (MS Office, this one and some Windows-only environments).
Code: Select all
dim c as integer
c(0) = 1
Code: Select all
dim c as string
c(0) = "A1"
Code: Select all
dim c as integer
c(0) = 1
c(1) = 2
c(3) = 3
print typename(c), c(999)
Code: Select all
dim c(1) as string
c(0) = "A1"
c(1) = "A2"
msgbox c(0)
msgbox c(2) 'Error
Code: Select all
dim c(1) as variant
X = 1
Y = "A2"
c(0) = X
c(1) = Y
print typename(c), c(0) , c(1)
Code: Select all
'very simple routine appending some element to an array which can be undimensioned (LBound > UBound)
Sub bas_PushArray(xArray(),vNextElement)
Dim iUB%,iLB%
iLB = lBound(xArray())
iUB = uBound(xArray())
If iLB > iUB then
iUB = iLB
redim xArray(iLB To iUB)
else
iUB = iUB +1
redim preserve xArray(iLB To iUB)
endif
xArray(iUB) = vNextElement
End Sub
Code: Select all
a = Array()
' print lBound(a), uBound(a) ' -1 to 0
bas_PushArray(a, "abc")
bas_PushArray(a, 123)
bas_PushArray(a, ThisComponent)