Solved

Add command button functions to menu in Excel

Posted on 2008-06-23
8
225 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

803 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