Results 1 to 2 of 2

Thread: How To Create An Add-In

  1. #1
    Grand Master
    Join Date
    Apr 2011
    Posts
    22
    Rep Power
    10

    How To Create An Add-In

    Here's a simple way to create your own add-in. Basically, an add-in has two broad steps.

    So the first step to create an add-in would be to create your sub-procedure or routine that you want to run by using your add-in.

    Second, you create controls / menus for the user so that they can simply click on a button to execute your macro.

    Here's the basic code that covers these two steps

    Code:
    Sub Auto_Open()
    
        Dim objCB As CommandBarButton
        
        Call Auto_Close
        Set objCB = Application.CommandBars("Ply").Controls.Add(Type:=msoControlButton)
        With objCB
            .Style = msoButtonIconAndCaption
            .Caption = "&Add Sheet..."
            .OnAction = "AddSheet"
            .FaceId = 245
            .Visible = True
        End With
        
    End Sub
    
    Sub Auto_Close()
    
        On Error Resume Next
        Application.CommandBars("Ply").Controls("&Add Sheet...").Delete
        Err.Clear: On Error GoTo 0
    
    End Sub
    Private Sub AddSheet()
    
        Dim sht As Object
        Set sht = ActiveSheet
        With Application
            .EnableEvents = 0
            .ScreenUpdating = 0
        End With
        ActiveWorkbook.Worksheets.Add After:=ActiveSheet
        sht.Activate
        With Application
            .EnableEvents = 1
            .ScreenUpdating = 1
        End With
        
    End Sub
    Attached Files Attached Files
    Last edited by Excel Fox; 07-03-2011 at 12:15 AM.

  2. #2
    Junior Member
    Join Date
    May 2011
    Posts
    14
    Rep Power
    0
    Thank you.

    I was looking for something like this.

    Greetings.

Similar Threads

  1. How To Create Executable COM Add-In
    By LalitPandey87 in forum Excel Help
    Replies: 2
    Last Post: 06-26-2012, 07:56 PM

Tags for this Thread

Posting Permissions

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