How to dected Excel was starting by automation (VSTO Addin context)

有些话、适合烂在心里 提交于 2019-12-08 07:14:38

问题


Context:

I'm running a VSTO Excel application context addin and I will load my addin also when MS Excel was started by an other process for automation in visible mode.

So now, it's necessary to know if MS Excel was started by an other process with automation e.g

  • CreateObject()
  • ExcelApplicatoin.Visible =true

("/automation -embedding")

At the the moment, I evaluate the following Excel Property:

ThisAddIn.Application.UserControl

But when MS Excel is started during CreateObject the property is alsways "False".

Does have anyone any idea to solve this problem? I have no other properties found to solve this problem.


回答1:


I think cmd arguments can be used:

bool isExcelStartedByAutomation = (Environment.GetCommandLineArgs().Contains("/automation") && Environment.GetCommandLineArgs().Contains("-Embedding"));


来源:https://stackoverflow.com/questions/28106231/how-to-dected-excel-was-starting-by-automation-vsto-addin-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!