如何遍历 Excel C# 实例
我可以使用 Marshal.GetActiveObject 访问内存中的 Excel 实例。但这总是返回最旧的现有实例。
我想遍历所有实例并能够选择要链接到的实例。
任何人都可以帮忙解决这个问题吗?
I can access an instance of Excel in memory using Marshal.GetActiveObject. But this always returns the oldest existing instance.
I would like to iterate though all instances and be able to choose the one to link to.
Can anyone help with this please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
编辑:
http://blogs 上有一篇文章完全实现了这一点。 officezealot.com/whitechapel/archive/2005/04/10/4514.aspx。 GetActiveObject 将始终返回表中的第一个对象。这是因为 Office 不注册新对象。您必须从子窗口获取应用程序。
编辑:
这是对我有用的代码。
Try this.
Edit:
There is an article that fully implements this at http://blogs.officezealot.com/whitechapel/archive/2005/04/10/4514.aspx. GetActiveObject will always return the first object from the table. This is because Office doesn't register new objects. You have to get the application from the child windows.
Edit:
This is the code that worked for me.