Ask Your Question
0

BASIC+Calc: How to Freeze Rows and Columns

asked 2019-10-15 10:28:39 +0100

lonk gravatar image

updated 2019-10-15 10:32:42 +0100

From this post, I have edited in order to freeze on a specific Sheet and it is not an active Sheet.

Dim oDoc As Object
oDoc = ThisComponent
oDoc.CurrentController.FreezeAtPosition(0,6)

It freezed on the active Sheet.

Can you please help me freeze on a specific Sheet which is not an active Sheet ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-10-15 15:42:15 +0100

mauricio gravatar image

updated 2019-10-17 04:40:47 +0100

This option, have sense only in visible sheet, so, you can apply when activate or activate and return to current activate sheet.

doc = ThisComponent
cc = doc.CurrentController
current = cc.Selection
sheet = doc.Sheets(0)
cc.select(sheet)
cc.freezeAtPosition(5,5)
cc.select(current)
edit flag offensive delete link more

Comments

@mauricio

Thank you so much for code and your explanation.

lonk gravatar imagelonk ( 2019-10-15 16:01:09 +0100 )edit

.

Sub FreezeRowsColumns
    TCCC = ThisComponent.CurrentController 
    TCCC.select( ThisComponent.getSheets.getByName( "Plan2" )
    TCCC.freezeAtPosition(6,5)
    TCCC.select(current)
    End sub
Schiavinatto gravatar imageSchiavinatto ( 2019-10-15 17:32:57 +0100 )edit

@mauricio

Sub FreezePane
'   Dim doc As Object : doc = ThisComponent
'   Dim cc As Object : cc = doc.CurrentController
'   Dim current As Object : current = cc.Selection
    Dim current As Object : current = ThisComponent.CurrentController.Selection
    ThisComponent.Sheets(0) 'Dim sheet As Object : sheet = doc.Sheets(0)
    ThisComponent.CurrentController.Select(ThisComponent.Sheets(0)) 'cc.Select(sheet)
    ThisComponent.CurrentController.FreezeAtPosition(5,5) 'cc.FreezeAtPosition(5,5)
    ThisComponent.CurrentController.Select(current) 'cc.Select(current)
End Sub

Is it possible to avoid variable namely 'current' ?

lonk gravatar imagelonk ( 2019-10-15 19:17:15 +0100 )edit
1

I don't understand, "avoid", you need save your reference to current sheet in some place if you want return after, but... that large lines are ugly for me.

mauricio gravatar imagemauricio ( 2019-10-15 19:33:47 +0100 )edit

.This one has freezing it removes and if it has no places.

sub FreezeRowsColumns2
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint" : args1(0).Value = "Plan1.$B$7"
createUnoService("com.sun.star.frame.DispatchHelper").executeDispatch(ThisComponent.CurrentController.Frame, ".uno:GoToCell", "", 0, args1())
createUnoService("com.sun.star.frame.DispatchHelper").executeDispatch(ThisComponent.CurrentController.Frame, ".uno:FreezePanes", "", 0, Array())
end Sub
Schiavinatto gravatar imageSchiavinatto ( 2019-10-15 19:42:57 +0100 )edit

@mauricio

Thank you so much for your explanation. So, that variable is for keeping the initial location.

And sorry for my long and disgusting code. This week I have just started learning LO BASIC after breaking up with MS Excel VBA which I have ever used for decades.

lonk gravatar imagelonk ( 2019-10-16 01:32:37 +0100 )edit
1

If you started with macros in LibreOffice, I recommended you start with Python, not Basic. Best regards.

P.S. Many year ago, I wrote macros in VBA too.

mauricio gravatar imagemauricio ( 2019-10-16 02:03:38 +0100 )edit

Dear @mauricio ,

Thank you so much for your concern.

After finishing my project on LO BASIC Calc, I will learn LO Python Calc.

Now many people are heading for LO Python Calc.

Can you please tell me why they prefer LO Python Calc in brief?

lonk gravatar imagelonk ( 2019-10-17 03:44:56 +0100 )edit

Where finish Basic, barely start Python.

mauricio gravatar imagemauricio ( 2019-10-17 04:41:03 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-10-15 10:28:39 +0100

Seen: 68 times

Last updated: Oct 17