2

I am using this script for horizontal scrolling using shift + mousewheel for excel:

#IfWinActive, ahk_class XLMAIN
+WheelDown::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,3,0)
+WheelUp::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,0,3)

It works great for tables but when I hold shift and scroll on graph sheets, I get this error:

Error 0x800A03EC -
Source: Microsoft Excel
Description: Unable to get the SmallScroll proprety of the Window class
HelpFile: xlmain11.chm
HelpContext: 0

Specifically: SmallScroll

        Line#
        002: Return
--->    002:
 ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,3,0)
        002: Return
        003:
 ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,3,0)
        003: Return
        004: Exit
        004: Exit
        004: Exit

Is there any way to fix this or will I forever be dragging the scroll bar because Excel's ux sucks?

I am using Excel 2016 on Windows 10.

Marcel
  • 298

4 Answers4

4

I know this is old but here is an answer for those who are looking for horizontal scrolling in excel.

The AutoHotKey script below works. I did some testing in Excel 2010 and it still scrolls fine on worksheets with Charts. If you have data in the chart selected, it actually will scroll along the data, which is interesting, if unexpected. However it will scroll horizontally as normal as long as you dont have the data in the chart selected. Hope this helps!

#Singleinstance Force

;Horizontal scrolling in Excel only #IfWinActive ahk_class XLMAIN

+WheelUp:: 
    SetScrollLockState, On 
    SendInput {Left} 
    SetScrollLockState, Off 
Return 

+WheelDown:: 
    SetScrollLockState, On 
    SendInput {Right} 
    SetScrollLockState, Off 
Return 

; Horizontal scrolling in everything except Excel. #IfWinNotActive ahk_class XLMAIN

+WheelDown::WheelRight
+WheelUp::WheelLeft

Nate
  • 613
  • 4
  • 12
2

I found the script above to be clumsy and slow: basically sends a set number of {Left} or {Right} commands. None of the AHK solutions seem to be reliable.

This program at GitHub works exceptionally well for horizontal scrolling both Excel and Word 2016 https://github.com/T800G/OfficeScroll Just press Shift and spin the wheel...

RobW
  • 31
0

use if to judge the type of activesheet, worksheet is -4167, chart is 3.

    #if WinActive("ahk_exe excel.exe")
        +wheelup:: ;scroll left
            xl := Excel_Get()
            if xl.ActiveSheet.Type = -4167
                xl.ActiveWindow.SmallScroll(0,0,0,3)
            return

        +wheeldown:: ;scroll right
            xl := Excel_Get()
            if xl.ActiveSheet.Type = -4167
                xl.ActiveWindow.SmallScroll(0,0,3,0)
            return
        #if

or u can use scrolllock instead

    #if WinActive("ahk_exe excel.exe")
        +wheelup:: ;scroll left
            SetScrollLockState, alwayson
            send {right 3}
            SetScrollLockState, alwaysoff
            return

        +wheeldown:: ;scroll right
            SetScrollLockState, alwayson
            send {left 3}
            SetScrollLockState, alwaysoff
            return
        #if
Wi11_l
  • 9
0
Ctrl + Shift + Scroll 

This works natively in Office 365. Better than the autohotkey solution, a lot more responsive.

I prefer to remap this to make it work without holding down Ctrl key. (Optional)

; Shift + Scroll

;Horizontal scrolling in Excel only #IfWinActive ahk_class XLMAIN +WheelUp:: Send ^+{WheelUp} Return

+WheelDown:: 
    Send ^+{WheelDown}
Return 

#IfWinActive

tinker
  • 350