Word and Excel 2000 question(s)

M

Michael Howes

I am writing Word and Excel documents from c#/.Net and it works great
with Office 2003

I can't even get the code to compile with Word/Excel 2000. There seems
to be a change in the way all the collections of objects are accessed
between versions 2000 and 2003

Any line of code where I do something like

WordApp.Selection.Cells[1].FitText = true;

or

table.Rows[index].Select()

wont compile

Cells, Columns, Rows, and Paragraphs don't seem to be enumerable or are
in a different way from 2000 to 2003

someone mind explaining the difference?
and how do I turn WordWrap off and FitText on for a Word table column in
Word 2000?? The above line with .FitText = true works great in Word 2003

thanks
mike

PS remove the x in my email address to respond directly.
 
H

Howard Kaikow

Michael Howes said:
I am writing Word and Excel documents from c#/.Net and it works great
with Office 2003

I can't even get the code to compile with Word/Excel 2000. There seems
to be a change in the way all the collections of objects are accessed
between versions 2000 and 2003


MSFT provided a PIA for Office 2002 and an even better one for Office 2003.
Thyere were significant changes in the interface.

Prior to Office 2002, the deed is mch harder.

If you want to do crossversion Office programming, good old VB 6 is the best
way to go.
 
M

Michael Howes

MSFT provided a PIA for Office 2002 and an even better one for Office 2003.
Thyere were significant changes in the interface.

Prior to Office 2002, the deed is mch harder.

I'm seeing a few things I don't understand

in my working Office 2003/C# code I use a lot of lines of code like
WordApp.Selection.Cells[1].FitText = true;

this doesn't work with Office 2000. Cells is not a indexable collection
After fooling around on a machine with Office 2000 I found an
equivalent line of code;
WordApp.Selection.Cells.Item(1).FitText = true;

I also needed to change the SaveAs calls because they take a different
number of parameters from 2000 to 2003 for both Word and Excel

I did all this by changing the reference from Word/Excel version 11 to
version 9.

I've run into two problems

First, when I'm coding on a machine that has Office 2003 now, the
reference seems to somehow get updated in the project to version 11.
This means the project won't even compile. I get errors about the
different number of parameters to SaveAs and the face that things like
Word.Cells does not contain a definition for Item

If I run the application compiled with a reference to Word/Excel 2000
on a machine with 2003 it works! But now I can't develop because the
reference is updated??

I'm at a loss for how to develop a c# application that can write a
Word and Excel document supporting both Office 2000 and Office 2003.


thanks
mike
 
H

Howard Kaikow

I'm at a loss for how to develop a c# application that can write a
Word and Excel document supporting both Office 2000 and Office 2003.

Take a look at the book "Microsoft .NET Development for Microsoft Office" by
Andrew Whitechapel.
 

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