1

I'm using vb.net, and trying to open an existing word file using Microsoft.Office.Interop. My code is as follows:

    Dim objWord As Word.Application
    Dim objDoc As Word.Document

    'Open Word
    objWord = New Word.Application
    objWord.Visible = True

    Try
        objDoc = objWord.Documents.Open(Application.StartupPath & "\GOS3_Leo.doc")
    Catch ex As Exception
        MessageBox.Show("Failed to load GOS3_Leo.doc")
        MessageBox.Show(ex.ToString)
        Exit Sub
    End Try

(with imports Microsoft.Office.Interop outside)

Every time the .Open method fails, and I see this error.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I have found many people on the internet with this error, but no solutions that work for me. I am using Visual Studio Express.

Help would be very much appreciated

-Harriet

Solved. Installed earlier version of Microsoft.Interop from Microsoft website. This silly girl should not be allowed near a computer.

  • Is your word able to open on the PC without the code? It might be a version issue. Try reading this blog as well http://www.codeproject.com/Articles/3959/Microsoft-Word-Documents-from-ASP-NET Microsoft say not to use interop - http://support.microsoft.com/kb/257757 Microsft example . http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getactiveobject.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 – indofraiser Sep 18 '13 at 10:02
  • Did you see this post? http://stackoverflow.com/questions/1111935/c-sharp-and-excel-interop What version of Office are you using? Is the version of the added reference identical to the one installed on your computer? – varocarbas Sep 18 '13 at 10:46
  • Installed earlier version of the reference. All works swimmingly. Thanks! – Harriet Meredith Sep 18 '13 at 11:55

0 Answers0