Mic*_*ski 2 c# process ms-publisher
有没有办法让现有的MS Publisher实例成为Microsoft.Office.Interop.Publisher.Application?
我发现了这个:
System.Diagnostics.Process.GetProcessesByName("Microsoft Publisher")
Run Code Online (Sandbox Code Playgroud)
所以我可以检查这是否已经运行,但如何将其转换为MS Publisher应用程序?所以我可以打电话Microsoft.Office.Interop.Publisher.Application.Open给例如?
小智 6
你可以尝试这个Microsoft getActiveObject.这是一个例子.
object word;
try
{
word = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
//If there is a running Word instance, it gets saved into the word variable
}
catch (COMException)
{
//If there is no running instance, it creates a new one
Type type = Type.GetTypeFromProgID("Word.Application");
word = System.Activator.CreateInstance(type);
}
Run Code Online (Sandbox Code Playgroud)
希望我帮忙!