Search code examples
vbaexcel-2007worksheet

Excel 2007 error "400 visual basic", when deleting worksheet


I've read this, this, and this, and none of the "solutions" worked for me.

I've restored MS Office Enterprise 2007 to default settings by running the Repair tool, via Control-Panel -> Add/Remove Programs -> MS Office Enterprise 2007 -> Change.

Every time I open a new workbook and it has the default 3 worksheets, when I try and delete a worksheet (right-click -> DELETE), I get that dreaded "400" error within a "Visual Basic" dialog box.

I found by trial-and-error, the only way to delete a worksheet was to use the Delete Worksheet command from the Toolbar custom menus.

There is obviously a macro attached to the right-click delete option, but I don't know how to remove it!


Solution

  • There are some auto loaded files in %USERPROFILE%\AppData\Roaming\Microsoft\Excel (and some other folders too) which doesn't get loaded in Excel Safe Mode (excel.exe /safe).

    You may want to list all the AddIns on the Excel onto ActiveSheet:

    Option Explicit
    
    Sub ListAddIns()
        Dim oAddIn As AddIn, r As Long
    
        ActiveSheet.Range("A1:F1") = Array("Name", "FullName", "IsInstalled", "IsOpen", "CLSID", "progID")
        r = 2
        For Each oAddIn In Application.AddIns
            With oAddIn
                 Cells(r, "A").Value = .Name
                 Cells(r, "B").Value = .FullName
                 Cells(r, "C").Value = .Installed
                 Cells(r, "D").Value = .IsOpen
                 Cells(r, "E").Value = .CLSID
                 Cells(r, "F").Value = .progID
                 r = r + 1
            End With
        Next
    End Sub
    

    The CLSID and progID can be helpful if the addin is part of a software package (search in Registry).