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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Corticus

Well-known Member
Joined
Apr 30, 2002
Messages
1,579
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
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
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>
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
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 ?
 

Corticus

Well-known Member
Joined
Apr 30, 2002
Messages
1,579
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
 

Forum statistics

Threads
1,144,734
Messages
5,725,983
Members
422,652
Latest member
Elnene1

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
Top