Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Alex
 
Posts: n/a
Default ActiveX Controls vs Form Controls

Excel helper(s)

I am reading a book on VBA and am confused over a point the author is trying
to make over controls.

With Form controls one can write a simple Sub procedure and assign it to the
button no problem. This I understand.

For ActiveX controls the author states...'If you try to create an event
procedure for an ActiveX control before the control exists, and you try to
reference that in your code, you will get compiler errors, so you have to
create the event procedure programmaticaly'.

What does this mean exactly?

If I place an ActiveX button on the worksheet and double-click then I can
add my code in the class module that will be of the type:

Private Sub CommandButton1_Click( )

There is no problem with this as I see it. Is the author's point that if you
add an ActiveX control using VBA then you must write the event procedure in
the VBA code too? In other words, you can't write an event procedure first
and then create the ActiveX control laterbecause they won't reference each
other?

The author does offer an example of this method and, whilst I understand the
VBA code, I don't understand in principle what the key idea is.

I am hoping that somebody on this list has better insights for this layman.

Regards

Alex
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default ActiveX Controls vs Form Controls

Alex,

I can't say I know what the author is actually saying, but you do not need
to create the code programmatically. I do not get a compiler if I create the
code before the control, and they do reference each other ok, I just tried
it. I would certainly advise against creating code programmatically as a
general practice.

As you have found, if you add an ActiveX control and double-click, the
template event is created for you, all you have to do is to fill in the
action code. This is the way I always do it.

I suggest you carry on with what works for me, and for you.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Alex" wrote in message
...
Excel helper(s)

I am reading a book on VBA and am confused over a point the author is

trying
to make over controls.

With Form controls one can write a simple Sub procedure and assign it to

the
button no problem. This I understand.

For ActiveX controls the author states...'If you try to create an event
procedure for an ActiveX control before the control exists, and you try to
reference that in your code, you will get compiler errors, so you have to
create the event procedure programmaticaly'.

What does this mean exactly?

If I place an ActiveX button on the worksheet and double-click then I can
add my code in the class module that will be of the type:

Private Sub CommandButton1_Click( )

There is no problem with this as I see it. Is the author's point that if

you
add an ActiveX control using VBA then you must write the event procedure

in
the VBA code too? In other words, you can't write an event procedure first
and then create the ActiveX control laterbecause they won't reference each
other?

The author does offer an example of this method and, whilst I understand

the
VBA code, I don't understand in principle what the key idea is.

I am hoping that somebody on this list has better insights for this

layman.

Regards

Alex



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
activex controls, no "Control tab" John Van Horn Excel Discussion (Misc queries) 2 November 16th 05 12:01 PM
Anchoring Activex Controls KG Excel Discussion (Misc queries) 2 March 24th 05 07:51 PM
After installing Office XP SP3, Excel ActiveX controls are moved a RJR Excel Discussion (Misc queries) 2 March 19th 05 05:54 PM
ActiveX Controls Display Issue? [email protected] Excel Discussion (Misc queries) 0 March 5th 05 05:43 PM
ActiveX Controls moving upon print/printpreview Steven Cheng Excel Discussion (Misc queries) 6 February 2nd 05 03:31 AM


All times are GMT +1. The time now is 05:35 PM.

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"