Solved

Macros set to a control button

Posted on 2000-03-08
6
155 Views
Last Modified: 2010-05-02
What is the code for clicking on a control button in excel that runs a macro?
0
Comment
Question by:mlouie23
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:vbWayne
ID: 2597565
Shell "C:\Program Files\Microsoft Office\Office\WINWORD.EXE /yourmacroname", 1
0
 

Author Comment

by:mlouie23
ID: 2597695
Edited text of question.
0
 

Author Comment

by:mlouie23
ID: 2597713
Hi vbWayne,
    Thanks for the help, but I'm sorry, I wasn't specific enough with my question.

     I've got a conrol button on one worksheet, and I want to run a macro within the same file on a different worksheet.  Does the line of code require to have "C:\Program Files\...etc?"
  Is there there a command/code more specific in excel?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:vbWayne
ID: 2598345
 
not sure on that one..I only have bits of code I've collected here and there..the code I gave you opens excel, a file, and runs a macro.


0
 
LVL 6

Accepted Solution

by:
andyclap earned 10 total points
ID: 2598600
You'll need to change the code for the event handler to be public, eg

Public Sub CommandButton1_Click()


then you can use
worksheetname.Commandbutton1_Click

from anywhere within the workbook
0
 

Author Comment

by:mlouie23
ID: 2605314
andyclap,

    Thanks so much for your knowledge!
It helped me a lot.

Take Care,

mlouie23
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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

19 Experts available now in Live!

Get 1:1 Help Now