none
How to make C# code continue to run after calling a VBA macro from Excel? RRS feed

  • Question

  • What I want to do is to test an Excel add-in which is implemented by VBA macro. I used C# code to open the Excel file, load .xla file and successfully triggered the macro which opened a dialog of the Excel add-in, then I want to use UI automation code to manipulate the UI, but i found that my C# code cannot continue running unless I close the application dialog which is triggered by Macro, is there any way to achieve what I want?

    Michael

    Friday, July 20, 2012 9:48 AM

Answers

  • you would have to span another thread in c# before invoking method that shows modal dialog and in that thread, after some time, send Enter Key (to simluate clicking Ok on message box) to your main thread (using for example SendKey class and WinFormSynchronizationContext)
    Friday, July 20, 2012 11:59 AM