Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Scroll in the sheet pane with the keyboard, possible?

I have document that contains about 40 sheet. Therefore I would like to be able to scroll in the sheet pane with the keyboard. However, I haven't found a way. Command - Page up and Command - Page down select previous and next sheet. Command - home and Command - end select first and last sheet. But the scrollbar remains in its position.


If someone could give me an applescript that took the scrollbar in the sheet pane to home and end, would that be apprecited.


Fred

iMac, Mac OS X (10.6.8)

Posted on Feb 12, 2013 8:26 AM

Reply
Question marked as Best reply

Posted on Feb 12, 2013 10:17 AM

Hello


Try something like this.


(*
    set scroll bar position of sheets area of Numbers 09
        0.0 = top
        1.0 = bottom
*)
tell application "System Events"
    tell process "Numbers"
        --set frontmost to true
        tell window 1
            tell splitter group 1 -- document pane
                tell splitter group 1 -- side pane
                    tell scroll area 1 -- sheets area
                        tell scroll bar 1
                            if exists then
                                set value to 1.0 -- [0.0, 1.0]
                            end if
                        end tell
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell


Scroll bar's value is in [0.0, 1.0].

0.0 is the top, 1.0 is the bottom, 0.5 is middle, etc.


Regards,

H

29 replies
Question marked as Best reply

Feb 12, 2013 10:17 AM in response to fred6633

Hello


Try something like this.


(*
    set scroll bar position of sheets area of Numbers 09
        0.0 = top
        1.0 = bottom
*)
tell application "System Events"
    tell process "Numbers"
        --set frontmost to true
        tell window 1
            tell splitter group 1 -- document pane
                tell splitter group 1 -- side pane
                    tell scroll area 1 -- sheets area
                        tell scroll bar 1
                            if exists then
                                set value to 1.0 -- [0.0, 1.0]
                            end if
                        end tell
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell


Scroll bar's value is in [0.0, 1.0].

0.0 is the top, 1.0 is the bottom, 0.5 is middle, etc.


Regards,

H

Feb 12, 2013 11:57 AM in response to Hiroto

I have this little snippet of script that might be the basis for scrolling through the sheet pane. It does not require there to be a scroll bar present. As written it will go to the second sheet and give that sheet focus. In the line "set targetSheetRow to second row...", if you change "second" to "first" or "third" (etc.) or "last" it will go to the that sheet instead. I'm not sure how to take this any further and turn it into a scroll script, though.




tell application "System Events" to tell application process "Numbers"

tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of front window

set targetSheetRow to second row where ((value of attribute "AXDisclosureLevel" is 0))


tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}


-- Focus the "Sheets" column ('outline 1 …') AFTER the target row is selected.

set value of attribute "AXFocused" to true

delay 0.1

end tell

end tell

Feb 12, 2013 12:01 PM in response to fred6633

A slight mod to Hiroto's script will let you bounce back and forth from top to bottom


tell application "System Events"

tell process "Numbers"


--set frontmost to true

tell window 1

tell splitter group 1 -- document pane

tell splitter group 1 -- side pane

tell scroll area 1 -- sheets area

tell scroll bar 1

if exists then

if value is 0.0 then

set value to 1.0 -- [0.0, 1.0]

else

set value to 0.0

end if

end if

end tell

end tell

end tell

end tell

end tell

end tell

end tell

Feb 12, 2013 1:11 PM in response to Badunit

Another slight to Hiroto's script: First run to the middle, sedond run to the end:

(*

set scroll bar position of sheets area of Numbers 09

0.0 = top

1.0 = bottom

*)

tell application "System Events"

tell process "Numbers"

--set frontmost to true

tell window 1

tell splitter group 1 -- document pane

tell splitter group 1 -- side pane

tell scroll area 1 -- sheets area

tell scroll bar 1

if exists then

if value is less than 0.5 then -- [0.0, 1.0] then --

set value to 0.5 -- [0.0, 1.0] end

else

if value is greater than or equal to 0.5 then -- [0.0, 1.0]

set value to 1.0

end if

end if

end if

end tell

end tell

end tell

end tell

end tell

end tell

end tell

Feb 12, 2013 3:00 PM in response to fred6633

Good idea to have multiple steps. However, it only scrolls downward then gets stuck at the bottom. Another IF would fix that.


Here is a script that will scroll down the sheets one by one, moving the focus to the sheet. When at the last sheet, it will take you to the top sheet. Sorry about the poor formatting.


tell application "System Events" to tell application process "Numbers"

tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of front window


-- Find the sheet that is currently being displayed

set currentSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and (value of attribute "AXSelected" is 1))



-- Try to move to the next sheet. If at thebottom, go to the first sheet

try

set targetSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and (value of attribute "AXSelected" is 0) and (value of attribute "AXIndex" is greater than (value of attribute "AXIndex" of currentSheetRow)))

on error

set targetSheetRow to first row where (value of attribute "AXDisclosureLevel" is 0)

end try


tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}



-- Focus the sheet after the target row is selected.

set value of attribute "AXFocused" to true

end tell

end tell

Feb 13, 2013 5:39 AM in response to fred6633

fred6633 wrote:


Thanks,


My idea was to have one for downwards and one for upwards.


There is already a key that goes down up one leverl, Cmd end and Cmd home.


Given the subject of this thread, I had assumed there was no way to scroll through the Sheets pane with the keyboard. It is not something I ever needed to do. But it turns out you are correct. There are built-in shortcuts for scrolling sheet by sheet (as I was trying to do) and for going to the top and bottom of the list of sheets (as Hiroto did). Cmd Page Up and Cmd Page Down are the two shortcuts for going up/down one sheet. Cmd Home and Cmd End go to the top and bottom.

Feb 13, 2013 6:09 AM in response to fred6633

Ok,

I finally got it to work as a service. Although Hiroto's script works when I run it in Automator, nothing happens when I try use them as services. But it worked when I added some lines:


(*

set scroll bar position of sheets area of Numbers 09

0.0 = top

1.0 = bottom

*)

tell application "System Events"

activate

tell process "Numbers"

--set frontmost to true

tell window 1

tell splitter group 1 -- document pane

tell splitter group 1 -- side pane

tell scroll area 1 -- sheets area

tell scroll bar 1

if exists then

set value to 0.0 -- [0.0, 1.0]

end if

tell application "Numbers"

activate

end tell

end tell

end tell

end tell

end tell

end tell

end tell

end tell


Adding "activate" under "System Events" worked but Numbers was unfocused after.

Adding "activate Numbers" got Numbers refocused. It flashes a bit, but anyway it works.

Feb 13, 2013 6:33 AM in response to Jeff Shenk

Jeff Shenk wrote:


Badunit,


I think the problem is that while the existing shortcuts move the focus up and down, the view doesn't scroll with the focus, so you can't see where you are if you have more sheets than fit in the window.


I think I need to brush up on my reading comprehension skills. I went off to solve a problem that wasn't the problem (and wasn't a problem at all for that matter).

Scroll in the sheet pane with the keyboard, possible?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.