none
Porting a Word AddIn between Office versions RRS feed

  • Question

  • Hi there,

    I have written a Word AddIn for Word 2007, but it turns out our main customer is using Word 2003 instead and misinformed us (argh).  I've succeeded in copying the source to a Word 2003 project without too much pain but I designed the primary UI for Word 2007 so it is trying to make a tab for the AddIn with a ribbon under it.  This is not working.

    The bizarre thing, though, is that when I look for other Office-specific UI bits in the available project controls, I can only get Word 2007-style objects, even though it is a Word 2003 project.  I am using Visual Studio 2008.

    What kind of control should I be creating to let Word 2003 see our code, and how do I find it?

    Thanks!


    Andrew
    _|_.
    |..|
    |_.|_/
    Monday, May 23, 2011 9:59 AM

All replies

  • Hi Andrew

    Is Word 2003 installed on the development machine? If not, then you won't be able to use that library (and your code probably won't compile correctly for deployment to a 2003 machine).

    Word 2003 uses the CommandBars object model, rather than the Ribbon. That is still available in the 2007 object models, but you won't be able to really test it in that version.

    Is this a VSTO add-in, or a Shared Add-in?


    Cindy Meister, VSTO/Word MVP
    Monday, May 23, 2011 10:32 AM
    Moderator
  • It's a VSTO add-in, and Word 2007 is already installed on the development machine—as I say, we were developing for Word 2007 expecting it to be our primary target!  I have Word 2003 on a separate test machine.

    That explains a lot, anyway; is the Word Object Model backward compatible, and is there a build option you can set to allow only 2003-compatible objects and calls?  I have changed all my WordOpenXML calls to get_XML(false) already, and otherwise we mainly use stuff like Word.Range objects and the sentences collection.

    Thanks!


    Andrew
    _|_.
    |..|
    |_.|_/
    Monday, May 23, 2011 10:40 AM
  • Hi Andrew

    Mmm, you'll need 2003 on a development machine to compile this properly - and it can't be a parallel installation with 2007. VSTO won't accept that and it would screw up your registry pretty royally.

    If you're not using content controls or building blocks, or anything else new in 2007, the code itself should run OK. Range and Sentences haven't changed that I know of, but you'll want to test it thoroughly because there are always these little things... Especially with the move to the new file format all kinds of things are turning up that have been "broken". We saw this back when we moved from the pre-Word 97 to the Word 97 file format... Word's just so huge and complex - and the people on the dev team tend to change so don't understand all the little "bits and pieces" that aren't used "every day".

    I'm going to move this discussion to the VSTO forum, then, where you'll get more support in case other issues (deployment, for example) crop up.


    Cindy Meister, VSTO/Word MVP
    Monday, May 23, 2011 10:48 AM
    Moderator
  • I'm about to uninstall Word 2007 from my wheezy old desktop machine so I can dev for 2003 on there—any registry entries or stuff I should manually clean up after the uninstall?

    Thanks!


    Andrew
    _|_.
    |..|
    |_.|_/
    Friday, May 27, 2011 10:30 AM
  • Hi Andrew

    Yes, I think 2007 does leave some stuff in the Registry that needs to be removed in order for things to work properly. Unfortunately, I don't have it memorized, but there have been discussions in the forum (dating back from the time 2007 was new and/or in beta). As I recall, the key set is the Registry entries that point to the PIAs...

    See if the information in this article (section concerning the Registry) helps you track down left-over bits-and-pieces:
    http://support.microsoft.com/kb/928218

    Also
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d6cd4f99-ca5f-407c-8fc3-1d5197e3e47a/
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/08f13e9d-895c-4102-b6d9-e327af8cf8c0/


    Cindy Meister, VSTO/Word MVP
    Monday, May 30, 2011 7:05 AM
    Moderator
  • Hi Andrew

    Mmm, you'll need 2003 on a development machine to compile this properly - and it can't be a parallel installation with 2007. VSTO won't accept that and it would screw up your registry pretty royally.

    If you're not using content controls or building blocks, or anything else new in 2007, the code itself should run OK. Range and Sentences haven't changed that I know of, but you'll want to test it thoroughly because there are always these little things... Especially with the move to the new file format all kinds of things are turning up that have been "broken". We saw this back when we moved from the pre-Word 97 to the Word 97 file format... Word's just so huge and complex - and the people on the dev team tend to change so don't understand all the little "bits and pieces" that aren't used "every day".

    I'm going to move this discussion to the VSTO forum, then, where you'll get more support in case other issues (deployment, for example) crop up.

    Hi Cindy,

    Thanks for your help. You are exactly right. And we strongly recommend developments to develop two add-ins for two versions.

     

    Hi Andrew,

     

    How about the issue now?

    Here is some additionally information about installation of multiple version Office:

    http://social.msdn.microsoft.com/Forums/en-SG/vsto/thread/ac98327f-7a0d-456e-8114-6a7e3f1aada9

    http://msdn.microsoft.com/en-us/library/ee819096.aspx

    And you’d better develop two add- in for Word 03 and 07, respectively. However if you want to build an add-in for both 03 and 07 anyway, you might need to refer to this blog:

    Can you build one add-in for multiple versions of Office?

     

    First, you need to target the lowest common denominator (Office 2003 in this case), and then write conditional code to use version-specific functionality dependent on which version you're actually running in. While you're doing this, it makes sense to abstract out the version-specific pieces to separate classes, or even to separate DLLs. Separate DLLs are particularly useful – because then, you could reuse these in multiple add-ins – either version-resilient add-ins or version-specific add-ins. You can build each version-specific DLL on a machine with that version of Office and the Office PIAs.

    Here's an example.

    ·         (On a machine with Office 2003) I build a DLL called Ui2003, with a set of CommandBar code.

    ·         Then (on a machine with Office 2007), I build a DLL called Ui2007, with a set of Ribbon and Task Pane code.

    ·         Then I build a VSTO Office 2003 Add-in.

    ·         Add references to both the Ui2003 and Ui2007 DLLs.

    ·         Write conditional code that detects the version of the host, and uses either the Ui2003 or Ui2007 functionality.

     

    And also this blog:

    Add-ins for Multiple Office Versions without PIAs


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Thursday, June 2, 2011 6:26 AM
    Moderator
  • Thanks Calvin, this is very helpful.  Unfortunately I am stuck trying to port the 2007 add-in to 2003 anyway ... I have already removed references to Content Controls from the 2003 code and we are going to ship separate builds for separate versions of Word, so conditionality should not be a problem as long as we can get a 2003 build out (our first customer required 2003 but somewhere in the pipeline we got told they were using 2007).

    I've rebuilt an old laptop with VS 2008 and Word 2003 as a build environment now and I have shunted the code across, and it seems to build fine, but now I am having another problem, namely that the add-in startup functions aren't being called when I launch an instance in the debugger.  I tried creating a new blank 2003 add-in and those functions aren't being called either, suggesting it's not just a problem specific to my code ...

    ... any thoughts?

    Thanks!


    Andrew
    _|_.
    |..|
    |_.|_/

    Sunday, June 5, 2011 3:28 PM