Results 1 to 12 of 12

Add-In not working when Excel called from command line

Threaded View

  1. #1
    Registered User
    Join Date
    12-07-2011
    Location
    PA,USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Add-In not working when Excel called from command line

    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 to ultimately do. If I double click on the .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 the old ‘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
    
        Application.COMAddIns.Update
        MsgBox Application.COMAddIns.Item("AddIn").Description
        Set addIn = Application.COMAddIns("AddIn")
        Set automationobject = addIn.Object
        automationobject.Startup
        MsgBox "After addin call"
    
    End Sub
    Any help greatly appreciated!
    Last edited by tweaver60; 01-31-2012 at 12:12 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