当我尝试这个时
oAssembly = Assembly.LoadFrom("C:\dynamicdlls\Microsoft.Office.Interop.Word.dll")
oType = oAssembly.GetType("Microsoft.Office.Interop.Word.Application")
Try
oObject = Activator.CreateInstance(oType)
Dim doc As Object = oObject.Documents.Open("C:\worddoc\test.docx")
Dim count As Integer = doc.Words.Count
For i As Integer = 1 To count
Dim text As String = doc.Words(i).Text
Console.WriteLine("Word {0} = {1}", i, text)
Next
oObject.Quit()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
我得到“无法创建接口的实例”。
我知道有一个更好的替代方案,我只是在探索这种方法,并想知道这是否可行以及如何做到这一点。