[Solved] Calc Macro FreezeAtPosition is relative to location

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
miryamb
Posts: 5
Joined: Tue Oct 07, 2014 10:53 am

[Solved] Calc Macro FreezeAtPosition is relative to location

Post by miryamb »

Hi,

I'm trying to write a very very basic Macro. I want it to Freeze the first line (to serve as headers).
When I used the dispatcher created automatically from the "record macro" - "dispatcher.executeDispatch(document, ".uno:FreezePanes", "", 0, Array())"
I got a popup asking if I want to set the first line as Headers.
in order to Avoid this popup I use:
"Doc.currentController.freezeAtPosition(0,1)".

My problem here is that it freezes the window relative to the active cell - i.e. If I'm standing on cell G16 when calling the Macro, it freezes the window at line 5, column F.

How can I make it work on the first line regardless of my current active cell? (I don't mind changing the active cell to A1, but for some reason no function I tried worked..)

Thanks a lot!
Miri
Last edited by miryamb on Tue Oct 07, 2014 4:43 pm, edited 1 time in total.
OpenOffice3.3.0
Linux
User avatar
RoryOF
Moderator
Posts: 35217
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by RoryOF »

The freeze is always to the cells above and to the left of the current cursor location, so you may need to move cursor to B1 to freeze A.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
miryamb
Posts: 5
Joined: Tue Oct 07, 2014 10:53 am

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by miryamb »

I figured as much :)

But I didn't manage to move the cursor to A1.

Tried:
Doc.CurrentController.GoToCell("A1")
and
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

Nothing worked..
OpenOffice3.3.0
Linux
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by Villeroy »

Don't select A1 when you want to split above A2.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
miryamb
Posts: 5
Joined: Tue Oct 07, 2014 10:53 am

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by miryamb »

it kept splitting at my original location
OpenOffice3.3.0
Linux
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by Villeroy »

Code: Select all

Sub freeze_row_one()
oView = ThisComponent.getCurrentController()
oView.freezeAtPosition(0,1)
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
miryamb
Posts: 5
Joined: Tue Oct 07, 2014 10:53 am

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by miryamb »

Tried this just now - didn't work ..
However I found out something interesting.

If my view includes the First line - it works fine (i.e. my location is C5)
If my view doesn't include the first line - it doesn't work (i.e. my location is Z50)

I need to change the view somehow.

Any ideas?
OpenOffice3.3.0
Linux
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by B Marcelly »

Code: Select all

Dim ThisController As Object, currPos As Object

ThisController = ThisComponent.CurrentController
currPos = ThisController.Selection
ThisController.FirstVisibleRow = 0
ThisController.freezeAtPosition(0,1)
ThisController.select(currPos)
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
miryamb
Posts: 5
Joined: Tue Oct 07, 2014 10:53 am

Re: In Calc Macro FreezeAtPosition is relative to my locatio

Post by miryamb »

Worked like a charm !!

Thank you very much :) I'll change the post name to solved

BTW - is there a place I can find all the fields of the controller (.Selection / .Select / .FirstVisibleRow)?
OpenOffice3.3.0
Linux
Post Reply