Results 1 to 5 of 5

Creating an Add-In can't get custom menu working

Threaded View

  1. #1
    Registered User
    Join Date
    03-22-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Creating an Add-In can't get custom menu working

    Hi,

    I am trying to create a new add in for excel. I have the add in created but I cant get a new custom menu working. It will not show up on the menu bar no matter what code I throw at it. I am new at doing this type of thing so I must be doing something wrong but I can't figure out what.

    I had been following instructions on this website:

    http://www.ozgrid.com/VBA/excel-add-in-create.htm

    Like I said I have the add-in created as an xla and when I run it from the VB editor t runs fine and the macro will run int he document. I am going to be distributing this addin to a few clients and just want to create a simple menu on the menu bar to be able to run the macro in the add-in but even though I used the code on that website no new menu is being added to excel.

    I am adding this code into "ThisWorkbook" in VB under the xla I made.

    Here is the code I am using:
    Option Explicit
    
    Dim cControl As CommandBarButton
    
    
    
    Private Sub Workbook_AddinInstall()
    
    
    
    On Error Resume Next 'Just in case
    
    	'Delete any existing menu item that may have been left.
    
    	Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
    
    	'Add the new menu item and Set a CommandBarButton Variable to it
    
    	Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
    
    	'Work with the Variable
    
    		With cControl
    
    			.Caption = "Super Code"
    
    			.Style = msoButtonCaption
    
    			.OnAction = "MyGreatMacro"
    
    			'Macro stored in a Standard Module
    
    		End With
    
    		
    
    	On Error GoTo 0
    
    
    End Sub
    
    Private Sub Workbook_AddinUninstall()
    
    	
    
    On Error Resume Next 'In case it has already gone.
    
    	Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
    
    	On Error GoTo 0
    
    End Sub
    Any help would be great.
    Last edited by royUK; 03-22-2010 at 03:11 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1