The following code will neither change the selection nor the focus-cell ('ActiveCell' in VBA).
Code: Select all
Sub scrollCellByRCtoTopLeft(Optional pCellByRC)
If isMissing(pCellByRC) Then pCellByRC = "R15C3"
REM Remove the example if no longer useful!
h = InStr(pCellByRC, "C")
r = 0 + Mid(pCellByRC, 2, h - 2) - 1
c = 0 + Right(pCellByRC, Len(pCellByRC) - h) - 1
doc = ThisComponent
cCtrl = doc.CurrentController
cCtrl.FirstVisibleRow = r
cCtrl.FirstVisibleColumn = c
End Sub