Keyboard shortcut to zoom in and out

Discuss the spreadsheet application
Post Reply
rdr713
Posts: 3
Joined: Tue Jan 31, 2012 2:55 pm

Keyboard shortcut to zoom in and out

Post by rdr713 »

I want a keyboard shortcut to zoom in and out of spreadsheets, so I did this:

Tools>Customize>Keyboard
Selected Shortcut keys:Ctrl+Shift+I, Category:View, Function:Zoom In, then "Modify"
Selected Shortcut keys:Ctrl+Shift+O, Category:View, Function:Zoom Out, then "Modify"
Selected "Okay"

I thought this would allow me to zoom in with Ctrl+Shift+I and zoom out with Ctrl+Shift+O, but nothing happens when I press those key combinations. What did I do wrong and how do I fix it?

Robert
Robert
San Francisco, Cal.

OpenOffice 3.3.0
Windows 7
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Keyboard shortcut to zoom in and out

Post by floris v »

OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
rdr713
Posts: 3
Joined: Tue Jan 31, 2012 2:55 pm

Re: Keyboard shortcut to zoom in and out

Post by rdr713 »

My problem has not been solved, that's why I posted it here. I don't understand: what made you think it had been solved?
Robert
San Francisco, Cal.

OpenOffice 3.3.0
Windows 7
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Keyboard shortcut to zoom in and out

Post by RoryOF »

It is good manners to link to your other postings on the same subject, so that a Solved query can readily be found if there is a solution.
 Edit: Try pulling the zoom slider, bottom right of screen. 
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Keyboard shortcut to zoom in and out

Post by floris v »

I didn't tag is as solved, did I?
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
rdr713
Posts: 3
Joined: Tue Jan 31, 2012 2:55 pm

Re: Keyboard shortcut to zoom in and out

Post by rdr713 »

I don't know about tagging, but you wrote, "If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar." But I see now that you apparently add that to every comment you post.

To RoryOF's suggestion about dragging the zoom slider: if you can tell me how to do that with a single combination keystroke then my problem will be solved and I can execute floris_v's instructions regarding solved issues.
Robert
San Francisco, Cal.

OpenOffice 3.3.0
Windows 7
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Keyboard shortcut to zoom in and out

Post by floris v »

That's in my signature. It's merely a reminder. And lots of people don't act on it, anyway. :(
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Keyboard shortcut to zoom in and out

Post by RoryOF »

In Andrew Pitonyak's document on OpenOffice Macros, in table 211 he gives hooks to zoom properties of the current document. It may be that you will need to write a macro to engage with these properties, then assign the Zoom up and Zoom down macros to shortcut keys. The starting point for OpenOffice macros is Andrew's document
http://www.pitonyak.org/OOME_3_0.odt
it is not a trivial read. There are other recensions of this (and similar information) on his site.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Keyboard shortcut to zoom in and out

Post by floris v »

More to the point: Can anyone confirm that the Zoom in and Zoom out items that you can link to keyboard shortcuts in the Tools - Customize section don't work? Wait, this thread is about the same problem. Apparently it hasn't been linked to an issue report.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
Hagar Delest
Moderator
Posts: 32664
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Keyboard shortcut to zoom in and out

Post by Hagar Delest »

+1. Can't set a shortcut to zoom in/out.
Definitively a bug.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Robert Tucker
Volunteer
Posts: 1250
Joined: Mon Oct 08, 2007 1:34 am
Location: Manchester UK

Re: Keyboard shortcut to zoom in and out

Post by Robert Tucker »

No, I can't get the zoom in or out to work assigning keyboard shortcuts on LibreOffice 3.4.4 on Fedora 16; tried when I saw the first two posts on the other forum.
LibreOffice 7.x.x on Arch and Fedora.
User avatar
qaz1qaz1qa
Posts: 103
Joined: Fri Jan 27, 2012 1:36 am

Re: Keyboard shortcut to zoom in and out

Post by qaz1qaz1qa »

I have assigned Zoom in, Zoom out to all kinds of keys and there is no responce.
Zoom,Scale Screen Display (apparently same thing as zoom) Does Work
It is possible to record a macro that will do what you want.
After recording a macro I placed it under MY MACRO and called it ZOOMIN

I got the following code

Code: Select all

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(0).Value = 87   '<---This Value can be changed
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
args1(2).Value = 0

dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())


end sub
I copied the code and pasted it into a new macro sheet named Zoomout and change the value noted above to a smaller number.

I then opened Tools > Customize > Keyboard >
Category + OpenOffice.OrgMacro + User + Zoomin and assigned it to the keyboard.
Ditto Zoom out.
Wala
Not sure if this does all that you want but you get the idea.

Was not that time consuming or just use the code above.
OpenOffice 3.3 XP If I am never wrong then I know everything and cannot improve. From the looks of things I have a lots to do.
xerostomus
Posts: 3
Joined: Sun Sep 02, 2012 4:52 am

Re: Keyboard shortcut to zoom in and out

Post by xerostomus »

You may try this macros. Just link keyboard shortuts with macros ZoomIn or ZoomOut

Code: Select all

sub ZoomIn( )
Zoom(5)
end sub

sub ZoomOut( )
Zoom(-5)
end sub


function Zoom(SStep as Integer)
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
Maginfication= thiscomponent.currentcontroller.viewsettings.zoomvalue() 'get current zoom
Magnification = Magnification + SStep 
if (Magnification < 20) then Magnification =20 'controls limits of zoom
if (Magnification >600) then Magnification =600

dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(0).Value = Magnification
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
args1(2).Value = 0
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())
end function
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Keyboard shortcut to zoom in and out

Post by acknak »

Just for the record, there is a standard shortcut included, although it's not strictly a keyboard shortcut: Ctrl+Mousewheel changes the zoom.
AOO4/LO5 • Linux • Fedora 23
pahmer
Posts: 3
Joined: Tue Sep 04, 2012 7:07 pm

Re: Keyboard shortcut to zoom in and out

Post by pahmer »

Xerostamus, thanks for the code, but I'm getting 0 for the Magnification each time. Any idea what I'm doing wrong? I simply copied your whole code.
Libreoffice 3.6, Win XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Keyboard shortcut to zoom in and out

Post by Villeroy »

Replace this line

Code: Select all

Maginfication= thiscomponent.currentcontroller.viewsettings.zoomvalue()
with these 3 lines:

Code: Select all

sv = thiscomponent.currentcontroller.viewdata
av = split(sv,"/")
Magnification = cInt(av(0))
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
User avatar
peterroots
Volunteer
Posts: 299
Joined: Mon Mar 03, 2008 6:33 pm
Location: UK

Re: Keyboard shortcut to zoom in and out

Post by peterroots »

Looking at LO bugs I found this https://bugs.freedesktop.org/show_bug.cgi?id=45705 which I have added a bit to
LibreOffice 4.0.3 OpenSUSE 12.3 : OpenOffice 4 Linux Mint 15
pahmer
Posts: 3
Joined: Tue Sep 04, 2012 7:07 pm

Re: Keyboard shortcut to zoom in and out

Post by pahmer »

Villeroy, your code fix didn't work for me, but I DID get it to work thanks to your code with a few tweaks:

sv = thiscomponent.currentcontroller.viewdata
av = split(sv,";")
Magnification = cInt(av(2))

The viewdata string is parsed by semicolons, rather than slashes, and the the current zoom factor is in the third position of the array.

I'm so pleased that this worked, since I have been hunting this topic for many months, and I once found a nice, elegant macro that worked, but I lost it in an upgrade, and I can no longer find the post that contained it, but this thread is an example of the forum at its best!

Thanks, xerostomus and Villeroy!
Libreoffice 3.6, Win XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Keyboard shortcut to zoom in and out

Post by Villeroy »

You posted in the Calc forum.
This instruction by xerostomus works perfectly well with Writer: Maginfication= thiscomponent.currentcontroller.viewsettings.zoomvalue()
your split(sv,";") works with Writer too.

Calc has no viewsettings. Calc has a ViewData string joined by slashes and the first element is the zoom. I tested this with a spreadsheet view.

In Impress and Draw ZoomValue is a direct property of the controller.
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
pahmer
Posts: 3
Joined: Tue Sep 04, 2012 7:07 pm

Re: Keyboard shortcut to zoom in and out

Post by pahmer »

I just tried it with calc also, and discovered my error! I was using Writer, as you pointed out. Sorry! Thanks for the lesson as well.
Libreoffice 3.6, Win XP
xerostomus
Posts: 3
Joined: Sun Sep 02, 2012 4:52 am

Re: Keyboard shortcut to zoom in and out

Post by xerostomus »

I bring the lates working version for Calk and Write.
:-)
xerostomus

Code: Select all

sub ZoomIn( )
Zoom(3)
end sub

sub ZoomOut( )
Zoom(-3)
end sub


function Zoom(SStep as Integer)
'this is for Libreoffice Write
rem ----------------------------------------------------------------------
rem define variables
dim Magnification as Integer
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
Magnification = thiscomponent.currentcontroller.viewsettings.zoomvalue() 
 	Magnification = Magnification + SStep
if (Magnification < 20) then Magnification = 20
'restore counting from 100
if ((Magnification > (100-abs(sstep))) and (Magnification < (100+abs(sstep)))) then Magnification =100
if (Magnification >600) then Magnification =600
'statusbar	
ThisComponent.CurrentController.StatusIndicator.setText("Magnification: " + Magnification)
'print typename(magnification)

'- new 2013-07-02 ------------------------------------------------------------
dim args3(3) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ZoomSlider.CurrentZoom"
args3(0).Value = magnification
args3(1).Name = "ZoomSlider.SnappingPoints"
args3(1).Value = Array()
args3(2).Name = "ZoomSlider.SvxMinZoom"
args3(2).Value = 20
args3(3).Name = "ZoomSlider.SvxMaxZoom"
args3(3).Value = 600

dispatcher.executeDispatch(document, ".uno:ZoomSlider", "", 0, args3())
end function

sub Zoom_calc_In( )
Zoom_calc(3)
end sub

sub Zoom_calc_Out( )
Zoom_calc(-3)
end sub


function Zoom_calc(SStep as Integer)
'this is for Libreoffice Calc
rem ----------------------------------------------------------------------
rem define variables
dim Magnification as Integer
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
	sv = thiscomponent.currentcontroller.viewdata
	av = split(sv,"/")
	Magnification = cInt(av(0))
 	Magnification = Magnification + SStep
if (Magnification < 20) then Magnification =20
'restore counting from 100
if ((Magnification > (100-abs(sstep))) and (Magnification < (100+abs(sstep)))) then Magnification =100
if (Magnification >600) then Magnification =600
'statusbar
ThisComponent.CurrentController.StatusIndicator.setText("Magnification: " + Magnification)
'print typename(magnification)

'- new 2013-07-02 -----------------------------------------------------
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ZoomSlider.CurrentZoom"
args1(0).Value = Magnification
args1(1).Name = "ZoomSlider.SnappingPoints"
args1(1).Value = Array()
args1(2).Name = "ZoomSlider.SvxMinZoom"
args1(2).Value = 20
args1(3).Name = "ZoomSlider.SvxMaxZoom"
args1(3).Value = 600

dispatcher.executeDispatch(document, ".uno:ZoomSlider", "", 0, args1())

end function
Last edited by acknak on Tue Jul 02, 2013 3:34 pm, edited 1 time in total.
Reason: code placed in code tags
lubuntu, LibreOffice 3.5.4.2
Build ID: 350m1(Build:2)
xerostomus
Posts: 3
Joined: Sun Sep 02, 2012 4:52 am

Re: Keyboard shortcut to zoom in and out

Post by xerostomus »

There works following command in Calc too:
Magnification = ThisComponent.getCurrentController().getPropertyValue( "ZoomValue" )
instead of these lines in previeous macro:
sv = thiscomponent.currentcontroller.viewdata
av = split(sv,"/")
Magnification = cInt(av(0))
lubuntu, LibreOffice 3.5.4.2
Build ID: 350m1(Build:2)
daniloperetti
Posts: 2
Joined: Fri Jun 19, 2015 7:05 pm

Re: Keyboard shortcut to zoom in and out

Post by daniloperetti »

OH! Thank you :bravo: because I had the same problem and this post solved!

I needed this after using Chrome and Firefox, so I'm used to using the zoom!!!

Congratulations!
OpenOffice 4.1.1 Windows 7
visthespoon
Posts: 1
Joined: Tue Mar 16, 2021 2:14 pm

Re: Keyboard shortcut to zoom in and out

Post by visthespoon »

Wow, really useful. long have I pulled my hair out at the lack of built in Zoom keys. So good to finally find this. Still can't believe there actually isn't one built in, and a you can't do the mousewheel shortcut with a laptop - I tried on the mousepad, but no dice.

Word of warning to noobs - I managed to competely overwrite all my existing macros as I had no idea how the macro code file worked. look into how to do it before just copying this code in ! but once it's in, it works a treat :)

https://neowiki.neooffice.org/index.php/Using_Macros
OpenOffice 4.1.7 on windows 10
Post Reply