Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reassigning a macro to an ActiveX button

I'm relatively new at using AcitveX. My issue is reassigning an AcitveX
button a new macro. How does one reassign a macro to an existing ActiveX
button which already has a macro assigned? I've exhaust all my resources here
at work and with the already posted issues with ActiveX controls here in the
help discussion board.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Reassigning a macro to an ActiveX button

If your button is from the Forms toolbar, then right click the button and
from the drop down menu, you should see Assign Macro. Click Assign Macro to
bring up a dialog box, click on the macro you want the button to run and it
should then appear in the top window of the dialog box. Click OK. and then
save the file. You are set.

If the button is from the Control Toolbox, then you have to enter design
mode by either clicking View Toolbars Control Toolbox and then click the
icon with the square and compass emblems in the upper left corner of the tool
bar to enter design mode, or open the Visuab Basic editor and click the icon
on the menu bar. Once in design mode, you can right click the button to
access a drop down menu. Click View Code to open the coce module for the
button. You should see this:

Private Sub CommandButton1_Click()
'Button's existing code here
End Sub

You can remove the existing code between the first and last lines and put
your new code in. Exit design mode, save the file and you are set.



"gengary" wrote:

I'm relatively new at using AcitveX. My issue is reassigning an AcitveX
button a new macro. How does one reassign a macro to an existing ActiveX
button which already has a macro assigned? I've exhaust all my resources here
at work and with the already posted issues with ActiveX controls here in the
help discussion board.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reassigning a macro to an ActiveX button

Thanks for the help. I'm able to change two of the buttons, but I now have
another issue 4 of the buttons seem to have a macro or control reference
directly assigned to the button. In the properties box instead of the normal
commandbutton1, a cmdprint appears which is a sub macro in the program. How
does one change the macro assigned to the button in this case? As you can
tell I'm really new at programming.

"JLGWhiz" wrote:

If your button is from the Forms toolbar, then right click the button and
from the drop down menu, you should see Assign Macro. Click Assign Macro to
bring up a dialog box, click on the macro you want the button to run and it
should then appear in the top window of the dialog box. Click OK. and then
save the file. You are set.

If the button is from the Control Toolbox, then you have to enter design
mode by either clicking View Toolbars Control Toolbox and then click the
icon with the square and compass emblems in the upper left corner of the tool
bar to enter design mode, or open the Visuab Basic editor and click the icon
on the menu bar. Once in design mode, you can right click the button to
access a drop down menu. Click View Code to open the coce module for the
button. You should see this:

Private Sub CommandButton1_Click()
'Button's existing code here
End Sub

You can remove the existing code between the first and last lines and put
your new code in. Exit design mode, save the file and you are set.



"gengary" wrote:

I'm relatively new at using AcitveX. My issue is reassigning an AcitveX
button a new macro. How does one reassign a macro to an existing ActiveX
button which already has a macro assigned? I've exhaust all my resources here
at work and with the already posted issues with ActiveX controls here in the
help discussion board.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Reassigning a macro to an ActiveX button

I neglected to menton that if you have more than one button you will need to
check the name because Excel automatically numbers them as you put them on a
sheet or a UserForm. From what you described the "cmdprint" appears to be a
name assigned by a previous code writer. If I am right, then you can use
that name in lieu of the CommandButton# part of the the coce.

expl: Private Sub cmdprint_Click() 'would replace CommandButton1_Click

You can test that easy enough. Simply right click the button and the View
Code. VBA will write the Click event line for you and it will use the
appropriate name. If
it does not write the code, click in the Declarations window, the small
window at top right of the code window, and then click on "click". But I
believe for the controls they automatically display the click event code
lines.

"gengary" wrote:

Thanks for the help. I'm able to change two of the buttons, but I now have
another issue 4 of the buttons seem to have a macro or control reference
directly assigned to the button. In the properties box instead of the normal
commandbutton1, a cmdprint appears which is a sub macro in the program. How
does one change the macro assigned to the button in this case? As you can
tell I'm really new at programming.

"JLGWhiz" wrote:

If your button is from the Forms toolbar, then right click the button and
from the drop down menu, you should see Assign Macro. Click Assign Macro to
bring up a dialog box, click on the macro you want the button to run and it
should then appear in the top window of the dialog box. Click OK. and then
save the file. You are set.

If the button is from the Control Toolbox, then you have to enter design
mode by either clicking View Toolbars Control Toolbox and then click the
icon with the square and compass emblems in the upper left corner of the tool
bar to enter design mode, or open the Visuab Basic editor and click the icon
on the menu bar. Once in design mode, you can right click the button to
access a drop down menu. Click View Code to open the coce module for the
button. You should see this:

Private Sub CommandButton1_Click()
'Button's existing code here
End Sub

You can remove the existing code between the first and last lines and put
your new code in. Exit design mode, save the file and you are set.



"gengary" wrote:

I'm relatively new at using AcitveX. My issue is reassigning an AcitveX
button a new macro. How does one reassign a macro to an existing ActiveX
button which already has a macro assigned? I've exhaust all my resources here
at work and with the already posted issues with ActiveX controls here in the
help discussion board.

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
how to disable/enable command button(ActiveX) using macro enahs_naneek Excel Discussion (Misc queries) 1 February 5th 10 12:32 PM
How do I run a macro with an activex button? geo Excel Discussion (Misc queries) 0 January 17th 06 10:55 PM
Reassigning macro locations for toolbar buttons dm59 Excel Discussion (Misc queries) 3 January 12th 06 05:58 PM
Reassigning macro to add in function Tom Corcoran Excel Programming 2 February 3rd 04 06:16 PM


All times are GMT +1. The time now is 04:08 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"