我使用以下代码进行了尝试,但它引发了异常。"Exception has been thrown by the target of an invocation."
System.Type wordType = System.Type.GetTypeFromProgID("Word.Application");
Object word = System.Activator.CreateInstance(wordType);
wordType.InvokeMember("Visible", BindingFlags.SetProperty, null, word, new Object[] { true });
Object documents = wordType.InvokeMember("Documents", BindingFlags.GetProperty, null, word, null);
object nullobj = Missing.Value;
string fileName=System.AppDomain.CurrentDomain.BaseDirectory + "assets\\sample_doc.docx";
object[] args = new object[15] { fileName, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj};
Object document = documents.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, documents,args);`