VBA Windows 10: Application.Run works under debugger but not under normal execution

0

I have a complex macro involving an entry point in one XLS file and several macros in other files. This has been developped and extensively tested under XP and I am currently trying to port it to windows 10.

Under Windows 10 and Excel 2013, I get a new problem which I don't understand

Sub Main
    Function1
    ' Some processing and reporting
    Function2
    ' Some more processing
    Function3
End Sub

Sub Function1 ' All FunctionX subs work the same

    With New Excel.Application
        .Visible = False
        With.Workbooks.Open("a different workbook")
            .Application.Run("MainFromThisWorkbook")
            .Application.DisplayAlerts = False      ' This line fails at Function2
            .Application.Quit
        End With
    End With

End Sub

That code which worked perfectly under XP and Vista now repeatedly crashes on the line after Application.Run on the second call (Function2) only. It says (roughly translated from my localized french excel) Execution error (..) 0x80010100 - 'Application' method of object '_Workbook' failed

Quick documentation lets me think the With'd Application object went bad during the process.

That error is specific to Windows 10 and happens only on second iteration. When I step over the Application.Run line, everything goes fine.

Is there something wrong in the way I call those macros from other workbooks? Can anybody give me insights on the problem that actually happens?

excel-vba
windows-10
vba
excel
asked on Stack Overflow Nov 21, 2017 by PPC • edited Jul 9, 2018 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0