VB  with Excel Add - ins Important Task Please help me !!!!!!!!  New Ideas

Posted on 2003-03-28
Medium Priority
Last Modified: 2010-05-01
Hello everyone's,

          I need to add one more menu item(Say Example TEST) to the Excel menu bar like[ File,Edit,View,Insert....TEST]. Like Add - Ins

The TEST menu having sub menus(like AddRecords,EditRecords). If i click the AddRecords(xls files are associated) the records are insert into PostrgreSql database tables.This is through VB with Excel object library.

I think this related to Excel macros(Add Ins).

i like to know how do create Add Ins(Excel) Through VB.......

Is it Possible.... i am new to this area.what ways can I accomplish this task?

I appreciate everyone's comments and helping me through this issue.

Advance Thanks,


Question by:suruthiblrkma
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
LVL 44

Accepted Solution

bruintje earned 152 total points
ID: 8227844
Hello suruthiblrkma,

you could start with a look here

just post back what happens


Assisted Solution

dmang earned 148 total points
ID: 8240060
You'll need a reference to the excel object library first (Project | References) from the VB menu.

You'll need to instantiate Excel
once excel is running, you can use the following to update the menu.

sub StartExcel()

    Dim oXLApp As Excel.Application
    Dim oXLBook As excel.workbook
    Set oXLApp = New Excel.Application  

    '... once the application is running, you can update
         the menu
    '... then open an existing workbook if needed

    Set oXLBook = oXLApp.Workbooks.Open("c:\test1.xls")

    .... do something ....
    Set oXLBook = Nothing
    Set oXLApp = Nothing

This will fo the following:

1. Add a new dropdown to the excel main menu.
2. Add a new button to the main-menu dropdown
3. Add a new dropdown to the dropdown

Sub AddToMainMenu()

    Dim cbb As CommandBarbutton
    Dim cbar As CommandBar
    Dim cBarPop As CommandBarPopup  
    dim cbarPopPop as commandbarpopup
    ' add a new main menu item
    With cbar.Controls
        .Add (msoControlPopup)
    End With
    ' define new item as dropdown
    Set cBarPop = cbar.Controls(cbar.Controls.Count)
    With cBarPop
        .Caption = "New Dropdown Menu"
        .Tag = .Caption
    End With
    'add button to dropdown
    Set cbb = cBarpop.Controls.Add(msoControlButton)
    With cbcNew
        .Caption = "new dropdown meun item"
        .OnAction = "subroutine_name"
        .BeginGroup = False
        .Tag = "New Dropdown Menu"
    End With
    'add dropdown menu to dropdown on main menu
    With cbarPop.Controls
        .Add (msoControlPopup)
    End With
    Set cBarPopPop = cbarPop.Controls(cbar.Controls.Count)
    With cBarPop
        .Caption = "New Dropdown DropDown"
        .Tag = .Caption
    End With

    set cbaropoppop = nothing
    set cbb = nothing
    set cbarpop = nothing
    set cbar = nothing

End Sub

Expert Comment

ID: 8531394
Hi suruthiblrkma,
This old question (QID 20566688) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.

Expert Comment

ID: 9440795
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Split between bruintje and dmang

Please leave any comments here within the next seven days.


Cleanup Volunteer

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 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