none
Where can I find the Library for adding a Word 2003 reference ? RRS feed

  • Question

  • Hi

    My question seems to be obvious, but after googleling a while, I can't find a right solution.

    I develop an application on my machine which needs to create a word file. My configuration is : VS 2010 and office 2007. Everything is OK, but this application is destinated to a person who works with Word 2003.

    When I add a reference, I only have the Office 12.0 library in VS 2010, and this library doesn't match with Office 2003.

    1/ Does it exist a library for both version 2003 and 2007 ?

    2/ Where can I find the right file for adding the Word 2003 reference ? I have access to the customer machine with Office 2003, so I can copy the right file for the reference, but which file is it ?

    Many thanks.

    Henri

     

    Saturday, January 15, 2011 9:21 PM

Answers

  • You will need to use Late Binding so that your code is independent of the version of Word on the user's machine.

    See the article "Early vs. Late Binding” at:
    http://www.word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm
     -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "foucauld" wrote in message news:7e848b09-ad69-4da9-8df6-fa90bd216b9a@communitybridge.codeplex.com...

    Hi

    My question seems to be obvious, but after googleling a while, I can't find a right solution.

    I develop an application on my machine which needs to create a word file. My configuration is : VS 2010 and office 2007. Everything is OK, but this application is destinated to a person who works with Word 2003.

    When I add a reference, I only have the Office 12.0 library in VS 2010, and this library doesn't match with Office 2003.

    1/ Does it exist a library for both version 2003 and 2007 ?

    2/ Where can I find the right file for adding the Word 2003 reference ? I have access to the customer machine with Office 2003, so I can copy the right file for the reference, but which file is it ?

    Many thanks.

    Henri


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Bessie Zhao Friday, January 21, 2011 10:31 AM
    Saturday, January 15, 2011 9:56 PM
  • Hi Henri

    The rule is, if you develop for multiple versions of Office, you always need to start with the "lowest common denominator". That is, with the oldest version of Office. Office is designed to be "backwards compatible" - things that work in the older version should usually work in the newer versions, as well. But the reverse is not necessarily true. And for this reason, if you set a reference to a newer version an older version cannot work.

    There are PIAs for all versions of Word, from Word 2002 forwards. These PIAs are all available as download redistributables on Microsoft, but they won't install if the required version of Office isn't installed. So there's really no way for you to reference an older set of PIAs if that version of Office isn't installed on a development machine.

    What's more, you shouldn't install multiple versions of Office in-parallel on a development machine. Most Office developers use virtual machine software to accommodate this restriction, such as VMWare or Virtual PC.

    Since you're using VS 2010, the simplest approach for you would be to 1) target the .NET Framework 4.0 and 2) embed those parts of the type library (think of it as embedding the Namespaces) your project uses into your solution. That would make your solution PIA- and thus version-independent.

    See the last section in this blog article: http://msdn.microsoft.com/en-us/magazine/ff796223.aspx
    And in this article, the section "To set the Embed Interop Types property": http://msdn.microsoft.com/en-us/library/dd264733.aspx

    If you don't want to do that, then you'd have to remove all references to the PIAs, declare all variables as type object, change all Enums to their integer value equivalent and use, as Doug suggests, late-binding for all calls to the "interop". For C# that would be GetType().InvokeMember().


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Friday, January 21, 2011 10:31 AM
    Sunday, January 16, 2011 8:26 AM
    Moderator

All replies

  • You will need to use Late Binding so that your code is independent of the version of Word on the user's machine.

    See the article "Early vs. Late Binding” at:
    http://www.word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm
     -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "foucauld" wrote in message news:7e848b09-ad69-4da9-8df6-fa90bd216b9a@communitybridge.codeplex.com...

    Hi

    My question seems to be obvious, but after googleling a while, I can't find a right solution.

    I develop an application on my machine which needs to create a word file. My configuration is : VS 2010 and office 2007. Everything is OK, but this application is destinated to a person who works with Word 2003.

    When I add a reference, I only have the Office 12.0 library in VS 2010, and this library doesn't match with Office 2003.

    1/ Does it exist a library for both version 2003 and 2007 ?

    2/ Where can I find the right file for adding the Word 2003 reference ? I have access to the customer machine with Office 2003, so I can copy the right file for the reference, but which file is it ?

    Many thanks.

    Henri


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Bessie Zhao Friday, January 21, 2011 10:31 AM
    Saturday, January 15, 2011 9:56 PM
  • Hi Henri

    The rule is, if you develop for multiple versions of Office, you always need to start with the "lowest common denominator". That is, with the oldest version of Office. Office is designed to be "backwards compatible" - things that work in the older version should usually work in the newer versions, as well. But the reverse is not necessarily true. And for this reason, if you set a reference to a newer version an older version cannot work.

    There are PIAs for all versions of Word, from Word 2002 forwards. These PIAs are all available as download redistributables on Microsoft, but they won't install if the required version of Office isn't installed. So there's really no way for you to reference an older set of PIAs if that version of Office isn't installed on a development machine.

    What's more, you shouldn't install multiple versions of Office in-parallel on a development machine. Most Office developers use virtual machine software to accommodate this restriction, such as VMWare or Virtual PC.

    Since you're using VS 2010, the simplest approach for you would be to 1) target the .NET Framework 4.0 and 2) embed those parts of the type library (think of it as embedding the Namespaces) your project uses into your solution. That would make your solution PIA- and thus version-independent.

    See the last section in this blog article: http://msdn.microsoft.com/en-us/magazine/ff796223.aspx
    And in this article, the section "To set the Embed Interop Types property": http://msdn.microsoft.com/en-us/library/dd264733.aspx

    If you don't want to do that, then you'd have to remove all references to the PIAs, declare all variables as type object, change all Enums to their integer value equivalent and use, as Doug suggests, late-binding for all calls to the "interop". For C# that would be GetType().InvokeMember().


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Friday, January 21, 2011 10:31 AM
    Sunday, January 16, 2011 8:26 AM
    Moderator