Macro to Hit Control Button

Travis

Well-known Member
Joined
Feb 26, 2002
Messages
1,711
Is there a way to make a macro click a control button named "Image1"
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

I assume you want to click the button to execute the code attached to the click event.

Just put this code in a new macro, and it will, in effect, 'click' it.

You can also use:
Image1.SetFocus

so the image is selected.

edit:
What's a control button?

HTH,

_________________<EMBED width="118" height="52" src="http://dacypha0.tripod.com/Images/Corticus.swf"></EMBED>
This message was edited by Corticus on 2002-11-07 12:22
 
Upvote 0
Use something like this:<pre>Private Sub CommandButton1_Click()
Call Image1_Click
End Sub

Private Sub Image1_Click()
MsgBox "Clicked on me!"
End Sub</pre>
 
Upvote 0
On 2002-11-07 12:20, Corticus wrote:
Hi,

I assume you want to click the button to execute the code attached to the click event.

Just put this code in a new macro, and it will, in effect, 'click' it.

You can also use:
Image1.SetFocus

so the image is selected.

edit:
What's a control button?

HTH,

The SetFocus method won't fire the Click event... did you edit that part Corticus ?
 
Upvote 0
I didn't really mean to say that setfocus was clicking the button, I was just saying to take the code that was triggered by pushing the button, put it where you wanted to put the command to push the button, and at the end of the code, use setfocus to make it look like the button was pushed.

Fortunately, the MVP's showed up to set things straight :)

Sorry for any confusion,
Corticus
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,289
Members
448,885
Latest member
LokiSonic

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