[Solved] Disabling Scroll Down on my SpreadSheet

Discuss the spreadsheet application
Post Reply
Tarkovsky
Posts: 29
Joined: Fri Jun 30, 2017 9:17 am

[Solved] Disabling Scroll Down on my SpreadSheet

Post by Tarkovsky »

Is it possible to create a macro to avoid someone to scroll down on my spreadsheet?
Last edited by Hagar Delest on Sat Jul 01, 2017 10:00 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.3 on Arch Linux
User avatar
Lupp
Volunteer
Posts: 3718
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Disabling Scroll Down on my SpreadSheet

Post by Lupp »

Probably you will get a helpful answer if you tell what you finally want to achieve.
After all you yourself also are "someone", and you surely would want to be able to scroll down if needed, wouldn't you?
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Tarkovsky
Posts: 29
Joined: Fri Jun 30, 2017 9:17 am

Re: Disabling Scroll Down on my SpreadSheet

Post by Tarkovsky »

I'm making a spreadsheet that has push buttons and text fields, It present the data in without showing the Scroll Bars, Menu Bar, Tool Bars and Status Bar.
So, It will act like a data app viewer, that's why I want to create a macro to disable the scroll.
In Excel VBA, I was using this macro:

Code: Select all

Sub blockscroll()

    Sheets("Sheet1").ScrollArea = "$A$1:$N$40"

End Sub
But now I'm porting all my job, so, basically, I want the samething that will do the same when I select the Sheet1, for example.
OpenOffice 4.1.3 on Arch Linux
User avatar
RoryOF
Moderator
Posts: 35106
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Disabling Scroll Down on my SpreadSheet

Post by RoryOF »

Do the users need to enter information? If not, you could Protect the sheet.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
Tarkovsky
Posts: 29
Joined: Fri Jun 30, 2017 9:17 am

Re: Disabling Scroll Down on my SpreadSheet

Post by Tarkovsky »

Yes, they will have text boxes and some cells will be avaliable to change.
OpenOffice 4.1.3 on Arch Linux
User avatar
Lupp
Volunteer
Posts: 3718
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Disabling Scroll Down on my SpreadSheet

Post by Lupp »

Sheets are objects of the same type as any CellRange in Calc. There will not be a property like 'ScrollAtrea' therefore.
Instead of restricting the scrollable Area you may hide columns and/or rows outside a specific CellRange which will also prevent scrolling thereto.
I still do not understand for what reason this must be done by a "macro". Why not simply save the doc with the amputated sheet?

If it must be done with a Sub the following one coded in OpenOffice BASIC should do.

Code: Select all

REM  *****  BASIC  *****

Sub SetVisibleRange(Optional pVisibleRange As String)
REM Set the default VisibleRange:
If IsMissing(pVisibleRange) Then pVisibleRange = "Sheet1.$A$1:$N$40"
theDoc   = ThisComponent
theSheet = theDoc.Sheets.GetByName(Split(pVisibleRange, ".")(0))
theRange = theSheet.GetCellRangeByName(Split(pVisibleRange, ".")(1))
theSheet.Columns.IsVisible = False
theRange.Columns.IsVisible = True
If theRange.RangeAddress.StartRow>0 Then 
    theRangeH = theSheet.GetCellRangeByPosition(0, 0 , 0 , theRange.RangeAddress.StartRow - 1)
    theRangeH.Rows.IsVisible = False
End If
If theRange.RangeAddress.EndRow<theSheet.RangeAddress.EndRow Then 
    theRangeH = theSheet.GetCellRangeByPosition(0, theRange.RangeAddress.EndRow + 1, 0, theSheet.RangeAddress.EndRow)
    theRangeH.Rows.IsVisible = False
End If
End Sub
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Villeroy
Volunteer
Posts: 31351
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Disabling Scroll Down on my SpreadSheet

Post by Villeroy »

Tarkovsky wrote:Is it possible to create a macro to avoid someone to scroll down on my spreadsheet?
A macro is overkill. Prepare your document with hidden rows and columns. If you need multiple documents in this style, use a template.
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
Tarkovsky
Posts: 29
Joined: Fri Jun 30, 2017 9:17 am

Re: Disabling Scroll Down on my SpreadSheet

Post by Tarkovsky »

Why not simply save the doc with the amputated sheet?
I'm sorry, that's because I was porting my existing code do OpenOffice/LibreOffice. Then I thought it would be possible to achieve this results only by a macro.
But your answers helped me a lot, thank you very much, It worked exactly the way I was looking for.
OpenOffice 4.1.3 on Arch Linux
Post Reply