如何连接到的展望从C#的运行实例连接到、实例

由网友(帅比男神思密达)分享简介:在VBA中,我通常使用 appOutlook = GetObject的(Outlook.Application)来获得的Outlook的运行实例,它抛出一个错误如果Outlook ISN吨运行。我通常这样做在Excel中,但现在我想看看我是否可以通过移动到C#,并从那里做它那里得到更好的效果。我需要做的是从Outloo...

在VBA中,我通常使用 appOutlook = GetObject的(Outlook.Application)来获得的Outlook的运行实例,它抛出一个错误如果Outlook ISN吨运行。我通常这样做在Excel中,但现在我想看看我是否可以通过移动到C#,并从那里做它那里得到更好的效果。我需要做的是从Outlook电子邮件复制并粘贴到Excel中,这样的表中的电子邮件得到粘贴成S preadsheet为单元格的值,而不是HTML。不过,我不太清楚如何做到这一点。我通常使用 Activator.CreateInstance ,但它是一个新的实例。我怎样才能连接到Excel和Outlook中的当前实例?

In VBA, I usually use appOutlook = GetObject(, "Outlook.Application") to get a running instance of Outlook, and it throws an error if Outlook isn't running. I normally did this in excel, but now I am wanting to see if I can get better results by moving to C# and doing it from there. What I need to do is copy emails from outlook and paste them into excel so that the tables in the email get pasted into the spreadsheet as cell values rather than html. However, I'm not quite sure how to do this. I usually use Activator.CreateInstance, but it makes a new instance. How can I connect to the current instance of Excel and Outlook?

推荐答案

您可以使用 System.Runtime.InteropServices.Marshal.GetActiveObject() 用于这一目的。

You can use System.Runtime.InteropServices.Marshal.GetActiveObject() for this purpose.

(请参见此相关的问题。)

阅读全文

相关推荐

最新文章