?
Solved

Add command button functions to menu in Excel

Posted on 2008-06-23
8
Medium Priority
?
232 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Accepted Solution

by:
Merch_Ops earned 1500 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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