Solved

assigning a macro to a button from within a macro

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vlookup for IP 3 73
excel VBA sending mail 9 49
Default Programs Does Not Show Excel 2010 Only Excel 2016 Even Though Both Installed 4 45
Create Form using Wizard 14 29
Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
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: …
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

930 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

12 Experts available now in Live!

Get 1:1 Help Now