Open Word 2008 Document - Memory Error

I am running the following code, which works fine in vs2003 (1.1), but seems to have now decided that I am using 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)

      

The error that occurs when trying to Open: "Attempting to read or write protected memory. This often indicates that other memory is corrupted."

Does anyone know how to fix this?

0


source to share


1 answer


Things to check:

  • Is Word installation sane (does a simple document open with a double click)?
  • antivirus tool not working (maybe a tool strictly about COM automation)?


One more note: since you are using VB.Net, there is no need to write all the "missing" parameters, the following code looks much simpler:

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)

      

0


source







All Articles