Re: Scrolling a spreadsheet with a macro

"Johnny Rosenberg" <[email protected]> Fri, 04 Mar 2011 21:19:09 +0100
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <op.vrt5d7byxqd8ry@pb-laptop>
Den 2011-03-04 17:56:12 skrev Niklas Nebel <[email protected]>:

> On 04.03.2011 17:18, Johnny Rosenberg wrote:
>> Have been looking for it with Xray, but so far I didn't find anything
>> that I think does what I want.
>>
>> What I want to do is to search for a cell. When I find it, I want it to
>> appear as the first row and the the first column. Let's say that I find
>> what I'm looking for in C7. Then I want the sheet to scroll so that it
>> appears like this:
>>
>> C D E F G H I J…
>> 7
>> 8
>> 9
>> 10
>> 11
>> 12
>> 13
>> 14
>> 15
>> ⁝
>
> Use the view's XViewPane interface. In Basic that's just
> oView.FirstVisibleColumn = 2
> oView.FirstVisibleRow = 6
>
> Niklas

Thanks! Your answer eventually lead me to the following subroutine:


Sub Scroll(Col As Long, Row As Long)
	ThisComponent.getCurrentController().setFirstVisibleColumn(Col)
	ThisComponent.getCurrentController().setFirstVisibleRow(Row)
End Sub

Works like a charm!

-- 
Kind regards

Johnny Rosenberg
--
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help