[Solved] Calc Macro FreezeAtPosition is relative to location
[Solved] Calc Macro FreezeAtPosition is relative to location
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
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
Linux
Re: In Calc Macro FreezeAtPosition is relative to my locatio
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
Re: In Calc Macro FreezeAtPosition is relative to my locatio
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..
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
Linux
Re: In Calc Macro FreezeAtPosition is relative to my locatio
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: In Calc Macro FreezeAtPosition is relative to my locatio
it kept splitting at my original location
OpenOffice3.3.0
Linux
Linux
Re: In Calc Macro FreezeAtPosition is relative to my locatio
Code: Select all
Sub freeze_row_one()
oView = ThisComponent.getCurrentController()
oView.freezeAtPosition(0,1)
End SubPlease, 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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: In Calc Macro FreezeAtPosition is relative to my locatio
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?
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
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
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
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: In Calc Macro FreezeAtPosition is relative to my locatio
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)?
Thank you very much
BTW - is there a place I can find all the fields of the controller (.Selection / .Select / .FirstVisibleRow)?
OpenOffice3.3.0
Linux
Linux