Add items to the ROT( Running Objects Table)

天涯浪子 提交于 2019-12-05 20:19:59

http://support.microsoft.com/kb/316126

COM servers are expected to register themselves in Running Object Table after startup. Office programs register themselves when they lose focus. If a program tries to attach to a running instance before the program loses focus, you may receive an error message. For additional information about how to work around this problem, click the article number below to view the article in the Microsoft Knowledge Base: 316125 PRB: Visual C# .NET Error Attaching to Running Instance of Office Application

Using code, you can change focus from the Office application to your own application (or to some other application) to allow it to register itself in the ROT. Additionally, if your code is starting the executable (.exe) file for the Office application, you may need to wait for the Office application to finish loading before you attempt to attach to the running instance.

Ensure another window is activated before attempting to connect. As shown in the example, you can use Form.Activate to focus your own form, thus causing the Office app to lose focus.

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