我正在执行以下代码,在vs2003(1.1)中运行良好,但似乎已经决定现在我正在使用vs2008(2.0 / 3.5):
Dim wordApp As Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.Document
missing = System.Reflection.Missing.Value
wordApp = New Microsoft.Office.Interop.Word.Application()
Dim wordfile As Object
wordfile = "" ' path and file name goes here
wordDoc = wordApp.Documents.Open(wordfile, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
尝试打开时抛出的错误是: “试图读取或写入受保护的内存。这通常表明其他内存已损坏。”
有没有人知道如何纠正这个问题?
答案 0 :(得分:0)
要检查的事项:
还有一句话:由于您使用的是VB.Net,因此无需编写所有“缺失”参数,以下代码看起来更简单:
Dim wordApp As Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.Document
Dim wordfile As String
wordApp = New Microsoft.Office.Interop.Word.Application
wordfile = "" ' path and file name goes here
wordDoc = wordApp.Documents.Open(wordfile)