Solved

Add command button functions to menu in Excel

Posted on 2008-06-23
8
220 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
  • 5
  • 3
8 Comments
 
LVL 9

Expert Comment

by:Merch_Ops
Comment Utility
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
Comment Utility
Alastair,
     Thanks, I will try ding this after lunch.

Rosemary
0
 

Author Comment

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

Rosemary
0
 
LVL 9

Accepted Solution

by:
Merch_Ops earned 500 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ilrosebud26
Comment Utility
Thanks,
    I will try this and see where I get.

Rosemary
0
 

Author Comment

by:ilrosebud26
Comment Utility
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
Comment Utility
Thanks for your help!!!
0
 
LVL 9

Expert Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

14 Experts available now in Live!

Get 1:1 Help Now