Add-In not working when Excel called from command line RRS feed

  • Question

  • I have developed an Excel Add-In in VS that has worked beautifully till this morning.  The add-in works fine when you startup Excel normally, and manually load an xslm file the calls a method in the add-in, from the Open menu item. It also works fine debugging in VS - Excel is fired automatically, Add-In is loaded, and can load an xlsm file that calls a method in the Add-In.  It also works when running excel from the command line – BUT it you run excel from the command line with the xxxx.xlsm as the parameter, it does not.  Same results if I try to fire excel from a C# app using the process.Start() - which is what I need.  If I double click on DirectLogin.xlsm from Windows Explorer, is works fine as well.   The error I’m getting is in the VBA function Workbook_Open() in the .xlsm I'm using – it blows when it attempts to access any method from the add-in

    I get ‘Object variable or With block variable not set’ when it hits the following line automationobject.Startup or any method in the add-in – it’s like it’s not loading the add-in properly, so it’s not available to call.  I've put in automationobject.COMAddIns.Update before I set an object to it, tried some waits as well - to no avail. 

    Workbook_Open method here:


    Private Sub Workbook_Open()
    Dim CmdRaw As Long
    Dim EqualLocation As Integer
    Dim CmdLine As String
    Dim QueueName As String
    Dim addIn As COMAddIn
    Dim automationobject As Object
        MsgBox Application.COMAddIns.Item("AddIn").Description
        Set addIn = Application.COMAddIns("AddIn")
        Set automationobject = addIn.Object
        MsgBox "After addin call"
    End Sub

    Any help appreciated.







    • Edited by tweaver60 Monday, January 30, 2012 8:02 PM
    Monday, January 30, 2012 8:01 PM