Forum Discussion
Running VBA code after clicking on a UserForm 'image'
- Apr 28, 2021
There is a textbox named TextBox1 on top of the Password text box.
So you actually enter the password in TextBox1, and the Password text box remains empty. Hence the message that the login information is incorrect.
Added later: the Image control actually does have a Click event, but it is hidden. See the replies by JonPeltier below.
The Image control does not have a click event. you can use the MouseUp (or MouseDown) event instead, with syntax
Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
' your code here
End Sub
with the name of your control instead of Image1, of course.
I am not sure of if this thread is actual, however, it looks like Image control has _Click event, despite it doesn't present in the VBA list.
If you type directly:
Private Sub Image1_click()
Excel will call that procedure on clicking the image area.
I have written an add-in for Excel 2003 for getting points from scientific graphic files.
It works well in Excel 2021.
Sincerely,
Andrey
- JonPeltierAug 05, 2022MVPAs I stated, the Click event dows not appear in the events dropdown of the UserForm code module when an image is selected in the Objects dropdown, but if you open the Object Browser, scroll to Image in the list of classes, right click on the list of members, and choose Show Hidden Members, you will see a gray entry for Click. This means you can write your own _Click event procedure from scratch.
- Andrey_KuzminAug 07, 2022Copper ContributorExcellent,
Thank you JonPeltier