3

When MATLAB R2015b interacts with Excel, it opens one Excel process and then keeps the process open until MATLAB is closed. When this happens, if I try to open a spreadsheet through File Explorer, it opens in an instance of Excel without add-ins loaded. Additionally, files opened like this will not auto-save or ask the user to save on exit.

If I open the Excel application through the start menu, the full Excel loads with all add-ins. Even after I have done this, opening new files through File Explorer will open in the add-in disabled version. Is there a way to force Excel to open the files in the version of Excel that has add-ins enabled?

I'm currently using Office 2013, MATLAB R2015b, and Windows 7.

UPDATE: I found a bug report and a MATLAB patch for part of this issue. It is here: https://www.mathworks.com/support/bugreports/1325577.

7
  • Do you have the preview pane activated on File Explorer? This sometimes causes problems when selecting and opening Excel files which use add-ins. If so, try turning it off. There may be some Excel processes running in the background - check with Task Manager and kill them first. Feb 25, 2016 at 9:55
  • You may add a "Open in New Window" option in the right-click menu for .xls and .xlsx file types, that launches Excel.exe with /x switch, and without DDE. I use Office 2010 so can't post the registry key locations.
    – w32sh
    Feb 26, 2016 at 7:58
  • For Excel 2010 (32-bit), can be adapted for 2013. pastebin.com/r3q6DR5P See also: superuser.com/questions/431061/…
    – w32sh
    Feb 26, 2016 at 8:02
  • @David the preview pane is not activated. Unfortunately the background Excel processes are part of having MATLAB open, so that's a non-starter.
    – John
    Feb 26, 2016 at 13:59
  • What happens if, for instance, a workbook_open event macro is in the workbook that was opened? Does it execute? Feb 26, 2016 at 16:35

1 Answer 1

3

It depends on the type of add-in. Basically you can have Excel add-ins (usually written in VBA) and COM add-ins which can be written in any language that understands COM. It can also depend where the the add-in is installed.

Excel add-ins in certain directories can be found and opened automatically. A common place to install Excel add-ins is at C:\Users\\AppData\Roaming\Addins. If an Excel add-in is stored here it can be opened from the File->Options->Addins tab in Excel or from the Developer tab if you have enabled it. After the add-in has been enabled in either place it will generally load whenever Excel is started.

COM addins are installed using an installer which places a reference to the add-in in the registry. Excel looks in the registry for these add-ins when it opens. The two locations I described above also contain lists of COM add-ins, and they can be enabled through these lists.

Also, you can force a workbook to open an add-in from VBA. When your workbook is opened, a routine named Workbook_Open is executed. Some code like this will force the addin to be installed.

Sub Workbook_Open()
    Const addinName as String = "insert the name of your add-in"

    If Not AddinLoaded(addinName) Then
        If AddinAvailable(addinName) Then
            On Error Resume Next
                Application.AddIns2(addinName).Installed = True
            On Error GoTo 0
        End If
    End If
End Sub

Function AddinAvailable(addinName As String) As Boolean
    Dim ad As AddIn

    On Error Resume Next
        Set ad = Application.AddIns2.Item(addinName)
    On Error GoTo 0

    AddinAvailable = Not ad Is Nothing
End Function

Function AddinLoaded(addinName As String) As Boolean
    Dim ad As AddIn, errNumber As Long

    On Error Resume Next
        Set ad = Application.AddIns2.Item(addinName)
        errNumber = Err.Number
    On Error GoTo 0

    If Not ad Is Nothing Then
        If errNumber = 0 Then AddinLoaded = ad.Installed And ad.IsOpen
    End If
End Function
1
  • While this won't work with new files in MATLAB, it will work for already saved files. Thank you!
    – John
    Mar 3, 2016 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .