Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 124
  • Last Modified:

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

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,

Suruthi


         
0
suruthiblrkma
Asked:
suruthiblrkma
2 Solutions
 
bruintjeCommented:
Hello suruthiblrkma,

you could start with a look here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dninvb00/html/ivb0085.asp

just post back what happens

HAGD:O)Bruintje
0
 
dmangCommented:
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 ....
   
    oXLBook.Close
    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
0
 
CleanupPingCommented:
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.
0
 
GPrentice00Commented:
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now