Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2008 VS 2008 Open Word文档-内存错误_Visual Studio 2008_Automation_Ms Word_Ms Office - Fatal编程技术网

Visual studio 2008 VS 2008 Open Word文档-内存错误

Visual studio 2008 VS 2008 Open Word文档-内存错误,visual-studio-2008,automation,ms-word,ms-office,Visual Studio 2008,Automation,Ms Word,Ms Office,我正在执行以下代码,这些代码在vs20031.1中运行良好,但现在我使用的是vs20082.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.

我正在执行以下代码,这些代码在vs20031.1中运行良好,但现在我使用的是vs20082.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)
尝试打开时引发的错误为: 试图读取或写入受保护的内存。这通常表示其他内存已损坏

有人知道如何纠正吗?

需要检查的事项:

Word安装是否正常?通过双击打开简单文档是否正常? 没有反病毒工具在运行可能该工具对COM自动化要求严格? 还有一句话:由于您使用的是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)