none
How to design an app to work with word 2003, 2005, 2010 in 32bit and 64bit environments? RRS feed

  • Question

  • Hello,

    I need to design an Word automation project which will deployed across non-homogenous end users. So it is needed that it works with word 2003, 2007 and 2010. Also it must work in 32bit and 64 bit environments.

    Give me some leads on how to design the app and its deployment.

    Regards,

    Nalini

    Friday, February 10, 2012 7:25 AM

Answers

  • What I meant was, that the end-user can install multiple Office versions in-parallel - he's allowed to do it and the will install. But the scenario is not supported and it's not guaranteed that everything will work.

    Best would probably be to have your setup program analyze the Registry to find out how many versions are installed, then create an entry for each of the versions it finds.

    Deployment is not my area of expertise. You'll need to start a new thread with an appropriate subject line to get an answer to this. Something like: "Registering add-in on machine with multiple versions of Word"


    Cindy Meister, VSTO/Word MVP

    Wednesday, February 15, 2012 7:00 AM
    Moderator

All replies

  • Hi Nalini

    Could you please provide more information about what this project should do?

    By "Word automation project" do you mean something that runs in-process or out-of-process with the Word application (and Add-in or a WinForm or...)?


    Cindy Meister, VSTO/Word MVP

    Friday, February 10, 2012 8:23 AM
    Moderator
  • Hello,

    I am looking at developing an Automatic Editing Tool which will be in Winforms.

    How different would it be if it has to be an Add-In ?

    Thanks for your help.

    Regards,

    Nalini

    Friday, February 10, 2012 8:51 AM
  • from UI perspective it does not have to be much different (the same screens can be developed for standalone WinForms app and office add-in). But from word object manipulation perspective there is some difference in regard to getting access to Word process. If you plan to always start your own process then you should only be careful about UAC, but getting access to existing, particular process requires enumeration of ROT, as each opened document will have its own entry. As for coding itself look at:

    http://blogs.msdn.com/b/andreww/archive/2008/09/02/version-specific-ui-in-add-ins.aspx 

    http://blogs.msdn.com/b/andreww/archive/2008/06/03/add-ins-for-multiple-office-versions-without-pias.aspx

    Friday, February 10, 2012 9:16 AM
  • Hi Nalini

    Can you please elaborate a bit more on what this Editing Tool should do? Mainly, it's a question for me why you'd use a Windows Form instead of Word, itself, for "an editing tool". In order to give you an optimal answer, we do need to understand what it is you want to do, in some detail.

    I get the feeling that the "best" approach might be for your Windows Form to generate a Word document using the Word OpenXML file format, but I can't be sure based on the limited information you've provided so far...


    Cindy Meister, VSTO/Word MVP

    Friday, February 10, 2012 9:41 AM
    Moderator
  • Hello,

    I will try to explain in short...

    The tool will be used by e-pub companies. The receive raw documents in all versions of word and these documents will be subject to a lot of user-specific rules and reformatted accordingly.

    Regards,

    Nalini

    Friday, February 10, 2012 10:09 AM
  • Hello Cindy,

    I found the article

    http://blogs.msdn.com/b/andreww/archive/2008/06/03/add-ins-for-multiple-office-versions-without-pias.aspxThe author has also given a sample code. Here the Add-in works in Word 2007 but doesn't in 2003.

    But my requirement is that it should work in both !

    Thanks in advance for ur help !

    Regards,

    Nalini

    Friday, February 10, 2012 11:39 AM
  • Hi Nalini

    You're still not giving us enough information about HOW these documents are going to be processed - the actual workflow. Without that, we simply cannot give you more than general information about what the best approach might be, and how it could be used across multiple versions of Word.

    What I can tell you is that you MUST program against the oldest version of Word. You cannot program against 2007 and expect it to work in 2003. Andrew Whitechapel does start from the basis of a 2003 solution.

    But it's been some time since he wrote that article, and some things have changed in the meantime. VS 2010, for example, has .NET 4.0, which allows you to embed Interop Types, making you independent of the PIAs. But you should still program on the basis of the oldest version, to make sure you use only functionality supported by ALL versions you're targeting.


    Cindy Meister, VSTO/Word MVP

    Saturday, February 11, 2012 6:51 AM
    Moderator
  • Hello Cindy,

    Programming against the oldest version is fine.

    Let me make this little clearer.

    My tool would sit as an Add-in in the version of the Word the end-user will have. It could be word 2003/2007 or 2010. Also the core code will be accessible by a WinForm app.

    Now, my challenge is - During installation, it should recognise the target version and if the end user is word 2003, it should add a Custom toolbar whereas if it is word 2007 and above, it should add a Ribbon.

    Hope I have made it little clearer.

    Regards,
    Nalini
    Monday, February 13, 2012 4:24 AM
  • Hello Cindy,


    Am elaborating a little bit more here...

    Tried the sample code given below.

    When I try to run it, the addin gets attached to Word 2007 but not to Word 2003.

    I would like it to get attached to both !

    Any ideas on how to go ahead...

    Thanks in advance.

    --------------------------------------Sample code-----


            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                if (Globals.ThisAddIn.Application.ActiveDocument != null)
                {
                    Word.Document activeDoc = Globals.ThisAddIn.Application.ActiveDocument;
                    activeDoc.Paragraphs[1].Range.InsertParagraphBefore();

                    string majorVersionString = Globals.ThisAddIn.Application.Version.Split(new char[] { '.' })[0];
                    int majorVersion = Convert.ToInt32(majorVersionString);

                    if (majorVersion >= 14)
                    {
                        // Add a check box content control.  
                        Word.ContentControl checkBoxContentControl1 = activeDoc.ContentControls.Add(
                            Word.WdContentControlType.wdContentControlCheckBox, activeDoc.Paragraphs[1].Range);
                        checkBoxContentControl1.Checked = true;
                    }
                    else if (majorVersion >= 12)
                    {
                        // Add a Windows Forms check box. This code requires a reference to Microsoft.Office.Tools.v4.0.Utilities
                        Microsoft.Office.Tools.Word.Document vstoDoc = Globals.Factory.GetVstoObject(activeDoc);
                        Microsoft.Office.Tools.Word.Controls.CheckBox checkBox1 = vstoDoc.Controls.AddCheckBox(
                            vstoDoc.Paragraphs[1].Range, 15, 15, "checkBox1");
                        checkBox1.Checked = true;
                    }
                    else if (majorVersion >= 11)
                    {
                        CheckIfMenuBarExists();
                        AddMenuBar();
                    }
                }

    ------------------------------end of sample code ----------------------

    Regards,

    Nalini

    Monday, February 13, 2012 9:22 AM
  • Hi Nalini

    Have you seen this discussion?

    http://social.msdn.microsoft.com/forums/en-us/vsto/thread/42BA3AA6-F253-4541-9835-4A20181FC469

    Basically, you install the files appropriate for the version of Word on the user's machine.


    Cindy Meister, VSTO/Word MVP

    Monday, February 13, 2012 10:02 AM
    Moderator
  • Hi Cindy,

    Thanks for pointing in the right direction.

    The issue is that if 2 or more versions of Word is there, the Add-in sits only on the latest installed version of Word !

    Regards,

    Nalini

    Monday, February 13, 2012 10:21 AM
  • Hi Nalini

    this is actually "by design". Microsoft does not support parallel installations of the Office products. The end-user can do it, but it's not a supported scenario.

    If you take a look at the Registry, you'll see that each version of Word has its own section under the HKCU/Software/Microsoft/Office. There's an Add-ins entry for each version. Your add-in would have to be listed under all the sections.


    Cindy Meister, VSTO/Word MVP

    Monday, February 13, 2012 10:58 AM
    Moderator
  • Hi Cindy,

    Can you please elaborate on how the end-user can do it ?

    What is the best way to do it ?

    Regards,

    Nalini

    Wednesday, February 15, 2012 4:57 AM
  • What I meant was, that the end-user can install multiple Office versions in-parallel - he's allowed to do it and the will install. But the scenario is not supported and it's not guaranteed that everything will work.

    Best would probably be to have your setup program analyze the Registry to find out how many versions are installed, then create an entry for each of the versions it finds.

    Deployment is not my area of expertise. You'll need to start a new thread with an appropriate subject line to get an answer to this. Something like: "Registering add-in on machine with multiple versions of Word"


    Cindy Meister, VSTO/Word MVP

    Wednesday, February 15, 2012 7:00 AM
    Moderator
  • Hi Cindy,

    Thanks for the help so far...shall start a new thread.

    Regards,

    Nalini

    Wednesday, February 15, 2012 7:04 AM