Results 1 to 16 of 16

execute an Add In

Threaded View

  1. #9
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: execute an Add In

    Hi --

    My ThisWorkbook now looks like this.

    Sub move()
    ActiveWorkbook.ActiveSheet.Columns("A:Z").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
    End Sub

    Private Sub Workbook_AddinInstall()
    
        On Error Resume Next
    
        'First thing the code does is remove the button if it hasn't been removed already
        Application.CommandBars("Worksheet Menu Bar").Controls("MyMacro").Delete
    
        'The above line results in an error if it has already been removed
        'So this On Error Resume Next ignores if there's an error and just resumes starting below
    
        Set MyMacro = Application.CommandBars("Worksheet Menu Bar").Controls.Add
        With MyMacro
            .Caption = "My Macro Button Name"
            .Style = msoButtonCaption
            .OnAction = "MyMacro" 'In your case this would be "move"
        End With
    
    End Sub
    Private Sub Workbook_AddinUninstall()
        
        On Error Resume Next
        Application.CommandBars("Worksheet Menu Bar").Controls("MyMacro").Delete
        
    End Sub
    So now i need to find out how to create a cmd button and where to put it!!! cheers!
    Last edited by Blake 7; 05-24-2011 at 05:03 PM.

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