Cannot use Items function in several Word classes from C# in Word

P

Phil

I have a C# .NET program that links to Word via a reference to MSWORD.OLB.
After I upgraded to Office 2003, I get compiler errors on
Word.Tables.Item(), Word.Columns.Item(), and Word.Templates.Item().

When I try the same code in Word VBA, it works.

Any ideas why this is suddenly unacceptable.

Phil
 
C

Cindy M.

Hi =?Utf-8?B?UGhpbA==?=,
I have a C# .NET program that links to Word via a reference to MSWORD.OLB.
After I upgraded to Office 2003, I get compiler errors on
Word.Tables.Item(), Word.Columns.Item(), and Word.Templates.Item().

When I try the same code in Word VBA, it works.

Any ideas why this is suddenly unacceptable.
Which version of Word did you upgrade FROM? My guess would be 2000, and that
your original project compiled against IAs that VisualStudio generated
automatically...

Note that Microsoft does NOT support using a single solution for multiple
versions of an Office program. MS recommends you create a solution for each
version you intend to support, tested and compiled against the (P)IAs for
that version. The automatically generated IAs for 2000 can differ
significantly from the *optimized* PIAs of another (later) version.

What you can try beyond separate solutions:
- Dave Thielen's "tweaked" the Word 2000 IAs to make them more "compatible"
http://www.thielen.com/users/dave/programming.htm

- Use Reflection (late-binding) to pick up the individual objects in a
collection where you're getting conflicts

Note that the office.developer.automation newsgroup would be the better venue
to pursue this kind of question than a VBA-specific group :)
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.office.
developer.automation&lang=en&cr=US

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top