Solved

assigning a macro to a button from within a macro

Posted on 1998-06-30
1
548 Views
Last Modified: 2008-02-01
I have a macro that creates a custom button on the toolbar. I want it to be automatically assigned to another macro.  Here's the code:

Dim msoButton As CommandBarButton

Set msoButton=Application.CommandBars("standard").Controls.
Add(msoControlButton, 2950, , 4)
   
I tried:

msoButton.OnAction = call print_claim
msoButton.Execute = print_claim
etc
etc

Nothing works.  Please help?    
0
Comment
Question by:leekk
1 Comment
 
LVL 3

Accepted Solution

by:
shalbe earned 100 total points
ID: 1612651
leekk,

This example adds a command bar control to the command bar named "Custom" and sets the macro named "MySub" to run whenever the button is clicked.

Set myBar = .CommandBars("Custom")
Set myControl = myBar.Controls _
    .Add(Type:=msocontrolButton)
With myControl
    .FaceId = 2
    .OnAction = "MySub"
End With
myBar.Visible = True


looks like for your macro the syntax should be:

           msoButton.OnAction = "print_claim"

that should do the trick for you. If not, let me know what happens.

Steve
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Article by: dandraka
There are several quick shortcuts that can make your life easier in Microsoft Programs.  These simple tips and tricks will your work more productive and you faster at completing your tasks! MS Word (1) Creating Re-usable Scraps You can create s…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now