Attempted to read or write protected memory while open a WordDocument

Discussion in 'Word Programming' started by AJ, Dec 9, 2009.

  1. AJ

    AJ Guest

    Hi ..I have a WinXP SP2 machine on which Office 2007 SP2 is
    installed.Things worked fine when office SP1 was installed.Since the
    time SP2 has been insatlled,I get the Below Exceptions when trying to
    open a WordDocument(.docx)
    Below are my lines of code
    Word.Document doc;
    object wordTrue = (object)true;
    object wordFalse = (object)false;
    object missing = System.Reflection.Missing.Value;
    object fileToOpen = targetDocxDoc;

    doc = Globals.ThisAddIn.Application.Documents.Open(
    ref fileToOpen,
    ref missing, ref wordFalse, ref wordFalse, ref
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing);

    The line Documents.Open gives teh following Exception Deatls ---

    System.AccessViolationException occurred
    Message="Attempted to read or write protected memory. This is often
    an indication that other memory is corrupt."
    at Microsoft.Office.Interop.Word.Documents.Open(Object&
    FileName, Object& ConfirmConversions, Object& ReadOnly, Object&
    AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate,
    Object& Revert, Object& WritePasswordDocument, Object&
    WritePasswordTemplate, Object& Format, Object& Encoding, Object&
    Visible, Object& OpenAndRepair, Object& DocumentDirection, Object&
    NoEncodingDialog, Object& XMLTransform)
    AJ, Dec 9, 2009
    1. Advertisements

  2. AJ


    I get the same exception. Did you manage to find the problem?
    , Sep 19, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.