Hover over userform

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
Office Version
  1. 2019
Platform
  1. Windows
I have a code that reduces the size and resize the useform back to the height default when i hover over my userform. Is there a way to reduce the size of my userform when I move away from the userform (i.e. cursor is not hovering over the userform)?

VBA Code:
Dim dHeight As Double

dHeight = 426
With Me
    If .Height = dHeight Then
        .Height = dHeight / 8
        .Top = Abs(Application.Top) + (Application.Height) - (Me.Height + 10)
        .Left = Abs(Application.Left) + (Application.Width) - (Me.Width + 10)
    Else
        .Height = 426
        .Top = Application.Top + Application.Height / 2 - .Height / 2
        .Left = Application.Left + Application.Width / 2 - .Width / 2
    End If
End With
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
An alternative would be to
- add another object (here Label1)
- use Label1 mousemove to shrink userform
- use userform mousemove to reinstate userform

VBA Code:
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'code posted above goes here
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'code to reinstate to correct size goes here
End Sub

UF.jpg
 
Upvote 0
I consider that, but I have seven objects can be clicked to perform a task. i rather not have a need to click an object to minimize or maximize the userform unless I performing a task using one of the objects

Currently, when i click an object on the useform, the userform is minimized. When I need to perform another task, I hover over the userform to maximize the userform. If Ii don't click an object, but move away from the userform, i want the userform to minimized
 
Upvote 0
ok...base on your suggestion (good idea), I increase the label length to the same size of the userform so that way I don't have to go to a specific spot on the useform to minimize it. i did the same thing at the top of the userform as well to maximize the form.

Thank you for the suggestion and the help
 
Upvote 0
that's the idea (y)
Make the objectt big enough to be useful ... BUT ... place it somewhere where you will not move the moue by accident! Otherwise it will be very annoying for you. ;)
 
Upvote 0
I placed it at the edge of the useform. All other objects are in the middle of the userform. That way if I need to minimize the userform, I have to purposely move the cursor to the edge of the userform. ??
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top