Find Width of Excel Scroll Bar

烈酒焚心 提交于 2019-12-11 12:43:30

问题


Activewindow.UsableWidth gives me the width of the screen with the Vertical Scroll Bar's width included. Is there a way I can calculate the width of the Scroll Bar? I measured it by having one shape be UsableWidth and the other shape be what I actually can see, and the difference is the width of the Scroll Bar. I'm wondering if there's a way to automate it so it can be used by a user with a higher or lower resolution, and therefore smaller or larger Scroll Bar.

Thank you!


回答1:


If you are looking to find the value for the vertical scrollbar width, you can use a Windows API call:

Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Public Const SM_CXVSCROLL = 2

______________________________________

Sub ShowVScrollWidth()

    Dim lVScrollWidth As Long

    lVScrollWidth = GetSystemMetrics32(SM_CXVSCROLL)

    Debug.Print lVScrollWidth

End Sub

(Adapted from the info on this page. More info on the available GetSystemMetrics parameters can be found at this MSDN page.)



来源:https://stackoverflow.com/questions/37491755/find-width-of-excel-scroll-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!