Tuesday, January 31, 2006

Turn to sheet having range and select range

This is not the most elegant way of doing things, but it works for turning to the sheet containing "rngname" and then selecting the range. It doesn't turn to the desired sheet until the last line.

oDoc = ThisComponent
oRanges = oDoc.NamedRanges
oNamedRange = oRanges.getByName(rngname)
oAddr = oNamedRange.getContent()
xPos = InStr(1,oAddr,".")-2
oAddr = Mid(oAddr,2,xPos)
oCells = ThisComponent.Sheets.getByName(oAddr).getCellRangeByName(rngname)
ThisComponent.getCurrentController.select(oCells)

No comments: