locked
Problem using Word (Microsoft.Office.Interop.Word.dll) RRS feed

  • Question

  • Hi ,
        I build an application which open word document and write some texts .
    I'm using Microsoft.Office.Interop.Word name sapce .

    When I run the application in my PC (Office 2007 exist) , everything working just fine. But when I try to run it in my customer PC (Office 2002 SP3) , I successfully open the Word application using :

    private Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new Microsoft.Office.Interop.Word.ApplicationClass();
    vk_word_app.Visible = true;
    vk_word_app.Activate();
    vk_visible = visible;

    but then , when I reach the Open function call the application crash :

    this.currentDocument = vk_word_app.Documents.Open(ref this.fileName,ref vk_missing, ref vk_read_only, ref vk_missing, ref vk_missing,ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing,ref vk_missing, ref vk_missing, ref vk_visible, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing);

    I got the following Exception:
    {"Attempted to read or write protected memory. This often an indication that other memmory corrupt."}

    Why ??????  What can I do ?
    is this happen because I'm using Microsoft.Office.Interop.Word.dll not support Office 2002 , where can I find such correct one :-(

    Saturday, May 31, 2008 4:28 PM

Answers

  • You need to reference the earliest version of Office you want your app to interop with.  Check for a PIA for Office 2002.
    • Marked as answer by [Joe] Sunday, June 1, 2008 7:43 AM
    Saturday, May 31, 2008 7:14 PM

All replies

  • Hi,
    I think that only Office versions 2003 and later are supported. Unfortunately I don't know any alternative methods of doing this. Hope someone can suggest something for you.
    Saturday, May 31, 2008 4:40 PM
  • You need to reference the earliest version of Office you want your app to interop with.  Check for a PIA for Office 2002.
    • Marked as answer by [Joe] Sunday, June 1, 2008 7:43 AM
    Saturday, May 31, 2008 7:14 PM
  •  I try to reference the earliest version of Office ,

    The problem is when I use Visual studio 2008 I got compile error,vk_word_app.Documents.Open "no function with 12 params" , but when do that in visual studion 7.1 this successfully compiled and work.

    Seems like some bad references between .Net 1.1,2 and my application .

    Sunday, June 1, 2008 7:46 AM
  • When did you install Office 2002 on your development machine or get the PIA for Office 2002?  When you started this thread you were using the Office 2007 interop.
    Sunday, June 1, 2008 8:37 AM
  •  I'm sorry, I don't understand your quistion, I'll try answer what I do understood.

    I didn't install Office 2002 on my development machine , What I do have is VS 7.1 .
    I develop the application using VS 2008 , Office 2007 installed on my development machine.

    I start this thread after I tried to run the application in deferent machine were it have Office 2002, VS 2008 , (No VS2008).

    What do you think about the following ideas (2) :
    1- Develope Word access library using VS 7.1 (which work with Office 2002)
        

    2- Try install PIA for Office 2002 , try use it as reference (Office 2002 Interop.Microsoft.Office.Word) in my application.

    Where can I find and download PIA for Office 2002 ?


    Regards,
    Joe
    Sunday, June 1, 2008 11:48 AM
  •  As I stated in my first reply.  If you want to interop with a particular office version, you must have an interop dll for that version or an earlier one.  If you want to use the Office 2007 PIA, make sure that all computers you expect to use it on have Office 2007 installed.  You can search MSDN for PIA's.
    Sunday, June 1, 2008 12:03 PM