https://github.com/cristianbuse/VBA-UserForm-MouseScroll
Use the Mouse Scroll Wheel to scroll VBA UserForms and Controls
https://github.com/cristianbuse/VBA-UserForm-MouseScroll
Last synced: 4 months ago
JSON representation
Use the Mouse Scroll Wheel to scroll VBA UserForms and Controls
- Host: GitHub
- URL: https://github.com/cristianbuse/VBA-UserForm-MouseScroll
- Owner: cristianbuse
- License: mit
- Created: 2019-02-13T20:53:53.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T15:00:05.000Z (8 months ago)
- Last Synced: 2024-08-28T16:34:36.818Z (8 months ago)
- Language: VBA
- Size: 3.93 MB
- Stars: 68
- Watchers: 10
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - cristianbuse/VBA-UserForm-MouseScroll - Use the Mouse Scroll Wheel to scroll VBA UserForms and Controls (VBA)
README
# VBA UserForm MouseScroll [](https://github.com/sancarn/awesome-vba)
MouseScroll is a VBA Project that allows Mouse Wheel Scrolling on MSForms Controls and Userforms.
- Multiple forms are tracked simultaneously. Just call the ```EnableMouseScroll``` for each form
- Both **MODAL** and **MODELESS** forms are supported (starting **12-Oct-2023**)!
- Debugging while the mouse is hooked is now supported (starting **12-Oct-2023**)!
- This library can be extended for clicks, double-clicks and movement inputs
- Both **vertical** and **horizontal** scroll are supported. Hold down Shift for horizontal scroll and Ctrl for Zoom## Installation
Just import the following 2 code modules into your VBA Project:
* [**MouseScroll.bas**](https://github.com/cristianbuse/VBA-UserForm-MouseScroll/blob/master/src/MouseScroll.bas)
* [**MouseOverControl.cls**](https://github.com/cristianbuse/VBA-UserForm-MouseScroll/blob/master/src/MouseOverControl.cls)To avoid any issues with the ```CR``` and ```LF``` characters, it is best to download the available [ZIP](https://github.com/cristianbuse/VBA-UserForm-MouseScroll/archive/refs/heads/master.zip) and then import the modules from there.
For anyone using specialized Mouse software please be aware that it might interfere with the mouse hook used in this project. For the following software, you only need to change some settings:
- X-Mouse Button Control (XMBC). See fix [here](https://github.com/cristianbuse/VBA-UserForm-MouseScroll/issues/20#issuecomment-1348040451)
- StrokesPlus. See fix [here](https://github.com/cristianbuse/VBA-UserForm-MouseScroll/issues/37#issuecomment-2028094854)## Usage
In your Userform use:
```vba
EnableMouseScroll myUserForm
```
For example, you can use your Form's Initialize Event:
```vba
Private Sub UserForm_Initialize()
Me.StartUpPosition = 0
Me.Left = Application.Left + Application.Width / 2 - Me.Width / 2
Me.Top = Application.Top + Application.Height / 2 - Me.Height / 2EnableMouseScroll Me
End Sub
```Not needed, but the following code can be added to the Form's Terminate Event:
```VBA
Private Sub UserForm_Terminate()
DisableMouseScroll Me
End Sub
```
Tracking of forms is done automatically by checking if the window is still valid and if the reference count of the form's object has any references left (except the internal ones used for raising events).## Notes
* You can download the available Demo Workbook for a quick start## Other Controls
* ```ListView```, ```TreeView```, ```WebBrowser``` etc. controls are supported without the need for any changes to the code## License
MIT LicenseCopyright (c) 2019 Ion Cristian Buse
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.