Solved

Add command button functions to menu in Excel

Posted on 2008-06-23
8
227 Views
Last Modified: 2010-04-30
I have a command button which links to a user form.  On the user form there are several administrative tasks: format files, archive files, ftp files.  Is there a why to create an option on the menu bar to drive this tasks?  For example, the menu option would say: MyFileFunctions and Contain Format, Archive and FTP.  If there is any additional information needed from me, please let me know.
0
Comment
Question by:ilrosebud26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 9

Expert Comment

by:Merch_Ops
ID: 21847239
Yes -

If not already done I would suggest you copy the code from the Click events of the buttons on your form into a new Module and turn them into normal Macros by renaming them like such:

sub ftp()
your code here...
end sub

Then right click on your menu bar and choose Customize...

Go to the Commands Tab. Scroll down the Catagories to find New Menu - from the Commands list drag New Menu up to your menu bar.

Next find Macros in the Categories list -  In the Commands list choose Custom Menu Item - drag this to the inside of your new menu. An box will then appear from which you can allocate one of your new macros to the button.

Alastair.

0
 

Author Comment

by:ilrosebud26
ID: 21847394
Alastair,
     Thanks, I will try ding this after lunch.

Rosemary
0
 

Author Comment

by:ilrosebud26
ID: 21847822
This works.  How do I activate if only a specific worksheet is open?

Rosemary
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 9

Accepted Solution

by:
Merch_Ops earned 500 total points
ID: 21847966
Easy way -
Record two macros -
One of you setting up the button on the menu.
One of you removing the button from the menu.

Go into the VBA window (alt+F11).

double click the ThisWorkbook in the project explorer to open the code window for the Workbook. You should see two drop down arrows currently labled (General) and (Declarations)

Change the General one to Workbook - this'll create a new event procedure called
Private Sub Workbook_Open()
under this put the line to call your build button macro e.g.
Call MacroBuild

Once done change the (Declarations) drop down to BeforeClose :
Private Sub Workbook_BeforeClose(Cancel As Boolean)
under this put the line to unload your build button macro e.g.
Call MacroUnBuild

You'll need to change one thing in the build macro though...
Application.CommandBars("Custom Popup 31225765").

should be changed to:
Application.CommandBars(12).
or whatever the number after CommandBars is in your recorded macro to unbuild the button.
0
 

Author Comment

by:ilrosebud26
ID: 21848071
Thanks,
    I will try this and see where I get.

Rosemary
0
 

Author Comment

by:ilrosebud26
ID: 21856817
I have created my add menu and delete menu macros and put them in this workbook declarations.  It seems to work OK.  Thanks!
0
 

Author Closing Comment

by:ilrosebud26
ID: 31469794
Thanks for your help!!!
0
 
LVL 9

Expert Comment

by:Merch_Ops
ID: 21856988
No probs, how come the B? Does anything need more clarification?
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
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…

726 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