Solved

assigning a macro to a button from within a macro

Posted on 1998-06-30
1
550 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction It seems that at least a couple of times per month, I answer a question that requires automating Outlook from another Microsoft Office application, usually (although not always) to send one or more email messages.  For example: …
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
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.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

773 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