Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default simulating click events

simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default simulating click events

Just double click on the Label.
It will take you to that labels Click event code.
Write your code there.
Don't forget to come out of design mode to try your code,
cause the event is not fired if you are in design mode.

Sharad

"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default simulating click events

Forgot to add that, go in to Design mode before double clicking.

"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default simulating click events

You can just call the subroutine. Since the click sub has private scope
within the sheet code, you'd have to call it from in there.

Another option, a better one imo, would be to put the code into its own sub
elsewhere and just have the click event call that subroutine.


--

Ray at work
Microsoft ASP/ASP.NET MVP


"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default simulating click events

Sorry I completely misunderstood your question.

When you want to fire the evenet for clicking on Label1 in Sheet1, you can
simply do

Run "Sheet1.Label1_Click"

You can use it even in a module.

Sharad

"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?





  #6   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default simulating click events

Thank you,

Unfortunately my question was still not explicit enough, it is a bit more
complicated than that as I am using a special work around to have several
hundred controls call the same code, and so the code has a recognizable
object on clicking, however just calling the code will not return an object,
but anyway I found another way to accomlplish what was needed. Thank you
though

"Sharad Naik" wrote:

Sorry I completely misunderstood your question.

When you want to fire the evenet for clicking on Label1 in Sheet1, you can
simply do

Run "Sheet1.Label1_Click"

You can use it even in a module.

Sharad

"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when clicked,
is there a way to cimulate actually clicking it so that the code for its
event is triggered?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default simulating click events

Ben,

It seems to me that you have a problem here.

Using the class code method to simulate control arrays, the event code gets
triggered on a control click. If you call it directly, the control is not
implicitly declared to the event. So, you need to make it known somehow,
such as a public variable, but this would negate some of the advantages (but
not all) of the control array method.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ben" wrote in message
...
Thank you,

Unfortunately my question was still not explicit enough, it is a bit more
complicated than that as I am using a special work around to have several
hundred controls call the same code, and so the code has a recognizable
object on clicking, however just calling the code will not return an

object,
but anyway I found another way to accomlplish what was needed. Thank you
though

"Sharad Naik" wrote:

Sorry I completely misunderstood your question.

When you want to fire the evenet for clicking on Label1 in Sheet1, you

can
simply do

Run "Sheet1.Label1_Click"

You can use it even in a module.

Sharad

"ben" wrote in message
...
simple question

Is there a way to simulate the clicking of a control through vba?

eg..
Sheet1 contains a label named 'l12' and will change colors when

clicked,
is there a way to cimulate actually clicking it so that the code for

its
event is triggered?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simulating a Zodiac with a chart gtslabs Charts and Charting in Excel 2 March 16th 09 07:16 PM
Click events on Ecel Cells aftamath Excel Discussion (Misc queries) 4 September 28th 05 04:35 PM
Late Bound Object Click Events AWesner Excel Programming 7 December 24th 04 05:39 PM
Click events on charts Steve Excel Programming 3 May 29th 04 03:26 AM
trapping click events on shapes Matt I Excel Programming 3 August 15th 03 08:17 PM


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"