sigol

Hi

We need to write an app that can automate the mail merge process in MS Word. The trouble is our clients have a range of different versions installed. What is the most reliable method for automating versions 2000 through 2007 Can a single approach be taken or do we need to write code for each (gulp)

I assume it would be better using COM automation than interop or am I talking rubbish

Any advice would be appreciated.

Best wishes,

Sigol.



Re: Visual Studio Tools for Office MS Word Automation (2000, XP, 2003 & 2007) in C# ?

Cindy Meister

Hi Sigol

This question would best be addressed to the word.mailmerge.fields newsgroup.

I can tell you, however, that significant changes in the object model were made in Office 2002. So code for 2000 would probably have to be different, no matter whether you work from within COM or use managed code. 2002 through 2007 could probably use the same code, but of course you'd want to test to make sure something wasn't changed unintentionally. In any case, if you're thinking of programming in a strongly typed environment the method signatures should at least be the same :-)






Re: Visual Studio Tools for Office MS Word Automation (2000, XP, 2003 & 2007) in C# ?

sigol

Hi Cindy,

Thank you kindly for your help. If I chose a minimum supported level of 2002, then in your opinion which method of automation would you recommend, COM or managed code. I assume managed code but I am not sure about which Interop library to use, etc. My development platform is Vista & Office 2007. Any advice would be appreciated.

Best wishes,

Sigol.





Re: Visual Studio Tools for Office MS Word Automation (2000, XP, 2003 & 2007) in C# ?

Cindy Meister

Choose the automation method that best suits your requirements :-)

Office apps are COM, so execution will generally be faster if you use COM. Automation using managed code requires an additional interface, so will tend to be slower. If all you'll be doing is connecting a Word document's mail merge to a data source, then using COM will be more efficient.

If you require .NET-specific things (such as CASPOL) or Windows Forms, then managed code is the better choice. Or if you'd be using things that are handled better by managed code, use that.

In either case, as long as you program against the older version you shouldn't have any trouble executing your app against a newer version. Generally, the type library of a newer version will be accepted by the code (as long as you don't use anything that "no longer fits"). Test against all versions, of course. If you do run into anything that requires version-specific handling, you can branch the code. And don't forget: late-binding is also available to you.






Re: Visual Studio Tools for Office MS Word Automation (2000, XP, 2003 & 2007) in C# ?

sigol

Thanks for your help Cindy.