If I enable the Drag and Drop behaviour for a textbox on an Excel userform, I can trigger an event simply by hovering the mouse over the texbox. If I then move the mouse away without dropping the item onto the texbox, I want the event to be cancelled. Is there any way I can do this?
Simple example: I hover the mouse over the textbox, a checkbox is ticked. I move the mouse away without dropping and the checkbox is un-ticked.
By validating the DragState of the mouse I was able to do this:
If DragState = fmDragStateLeave Then
Related
VBA: How do I detect that I am moving the mouse pointer over a label control on a VBA Userform using VBA code?
I'm performing the following steps in my VBA application after starting the application and Initializing a userform:
I press my left mouse button down while the mousepointer is over a Label control on a VBA userform
With my code in the Label_MouseDown event for the label I've click on, I get the x and y location of the mousepointer relative to the label control's upper left corner.
While the left mouse button is still pressed, I move my mousepointer and track the movement in the Label_MouseMove event.
At some point while moving the mouse pointer, I release the left mouse button, get the mousepointer's x, y location from the Lable_MouseUp event.
I then move the label to this new x, y location.
So far, I'm fine while I'm moving the mousepointer directly over the userform and that part is working perfectly.
My problem is that there are other Label controls on the userform and I want my code to detect when I'm moving my mousepointer over one of these other label controls while I have the left mouse button still pressed. I want to change the border, of the label I'm moving over, from none to a line. When I move away from the label I just moved over, I want to change the label's border back to no border.
I've experimented for hours with the Label_BeforeDragOver event and read every help document I could find, but it doesn't seem to be the appropriate event for solving my problem.
Anyone know a way to do this in VBA code?
I am developing a quotation process with VBA in an Excel Worksheet. I placed an ActiveX Frame control with 2 option buttons inside.
As soon as I leave Design Mode, the buttons disappear. I have made sure the buttons are visible, have the correct width and height and I know they are there because I can access them pragmatically.
The problem is, I guess, with the Frame control that probably has a bug.
Any advice will be greatly appreciated.
Cheers, EOutlook
To add an option button to your frame, right-click the frame and choose "Frame object >> Edit" - add the option button from the toolbox which pops up, not from the Developer ribbon.
I have a userform with a scrollbar and textbox.
How do you code it so that the scrollbar connects to the textbox?
For example, I want the textbox to increase/decrease by a value each time you click the up/down-arrow on the scrollbar.
You don't say what version of Excel you are using so see if this works for you.
To get a spinner or scrollbar to work you can connect it to a cell by right-clicking on the scroll bar control and selecting Properties | Format Control | Control and then select the cell by using the Cell Link property at the bottom to select and link the cell you want to increment/decrement by using the scrollbar
If you haven't already linked the textbox to that cell, you can do so by
First - select the text box
Second - put your cursor in the formula bar
Third - type in = symbol and then click on the above cell you want
to link to,
Finally - press the Enter key
I have many buttons on a worksheet ( can't remember if they are activeX or not). I'd like to add a few lines describing what each button does when the cursor is hovering over the button. Is this even possible?
I have created a small UserForm in Excel. I have created Button1 and have enabled the tab index. When I tab from a drop down box to Button1, it assumes that I have hit enter on the button, just by simply tabbing to it. Is there a way to disable this?
I want the user to tab to Button1 and then actually hit Enter or click. I am not sure why simply clicking tab after previous item is running the macro in Button1_Enter.
Thanks.
Place you code in the Button1_Click event instead of the Button1_Enter. As Tim points out, "Enter" refers to receiving focus and not clicking of the button hence the behavior you've described.