Skip to main content

Wiki

Content from https://github.com/Excel-DNA/ExcelDna/wiki

📄️ COM-object-model-notes

* You should only use the Excel COM object model from the main Excel thread. Thus not from other threads, Tasks that you create, timer callbacks that you set up. It's safe to call it from a ribbon callback, of any macro (ExcelCommand). If you have a timer or some other thread that needs to do work back on the main thread, you can start a macro context running on the main thread with a call to ExcelAsyncUtil.QueueAsMacro(...). This waits for Excel to be ready, then runs the delegate you pass. In there, you can use the object model.