Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add command button functions to menu in Excel

Posted on 2008-06-23
8
Medium Priority
?
233 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

604 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