Please Settle This Issue....(URGENT)

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

in my head......

I need my application to work with Office 97, 2000, XP and 2003 versions of
MS Word and MS Excel.

IN order to acomplish this I have to install in different folders:

1. remove my Office 2003
2. Install Office 97 Word and Excel
3. Install Office 2000 Word and Excel
4. Install Office XP Word and Excel
5. Reinstall my Office 2003
6. Open my project and add references for Word and Excel libraries 8?-11.
The libraries will be there then right?
7. REbuild project.......

Last time I did something like this I spent weeks trying to fix the mess it
turned into. I tried to install OFfice XP next to 2003 without taking 2003
off.

I so much do not want to go through that again....

Thanks again.
 
You should have Office 97 installed on your development machine, and your
project should only reference the Office 97 type libraries (version 8.0, I
think.)

The application will then be forward compatible to later versions of Office
as well. (In theory at least -- there are reports of a few subtle changes
in the Office object model that can introduce bugs, so test your application
thoroughly with other versions.) You can have other versions of Office
installed on your machine for testing purposes, but it isn't strictly
necessary.
 
Thank you for respoding. Plesae let me know what went wrong here.

After doing this (putting in 8.0) what I had before

Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core

isnt working. IT is saying:

C:\Documents and Settings\Administrator\My Documents\Visual Studio
Projects\MS Word Assistant\fmworddoc.vb(2): Namespace or type 'Word' for the
Imports 'Microsoft.Office.Interop.Word' cannot be found.

C:\Documents and Settings\Administrator\My Documents\Visual Studio
Projects\MS Word Assistant\fmworddoc.vb(3): Imports alias 'Office' conflicts
with 'Namespace Office' declared in the root namespace.


The dependency 'Interop.VBIDE' could not be found.
 
Pardon my VB6 here, but using it purly for example.

Isn't the way Microsoft Office products are designed that if you just do a
createobject type issue with

CreateObject("Word.Application") it automatically returns the appropriate
version as per the regsitry defintion?

Could we use the same idea here? And only interop the Excel 7.0 (97)
Library to ensure 100% backwards compatiblity?

-CJ
 
You can do that, but the references to Microsoft Word will then be
late-bound (of type "Object" instead of type "Word.Application.") This is
generally undesirable because you won't be able to use Intellisense in the
IDE, and increases the opportunities for bugs. There might be circumstances
where it's necessary, but it should generally be avoided.
 
I think your're just referencing the wrong library. To control Word, you
should just reference the "Word" namespace, instead of
"Microsoft.Office.Interop.Word." (This can happen when you switch back and
forth between libraries -- you get more DLLs in the "References" list than
you need, and it becomes a mess.)

It might be easier if you create a new project for testing purposes. This
worked for me (using the Office 2000 libraries -- don't have Office 97
installed on my dev machine):

1. Create a new WinForms application, and drop a button on it.

2. Add a COM reference to the appropriate Word library (8.0 for you.) In
addition to the standard references, you should have "Office," "VBIDE" and
"Word."

3. Insert the following code to handle the button's click event:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Debug.WriteLine("Opening Microsoft Word")
Dim App As New Word.Application

Debug.WriteLine("Showing Microsoft Word")
App.Visible = True

Debug.WriteLine("Quitting Microsoft Word")
App.Quit()

End Sub

It will open Word, make it visible, and then close it. It should also work
for any version of Word, 97 and higher.

If this works, then try clearing out all of the extraneous references in
your working application, and then add the reference to the Word 8.0 and/or
Excel 8.0 libraries again. You can just delete the "Imports..." lines and
make sure that your code is referencing the correct libraries.

Hope this helps!
 
What about Word.IApplication interface... Shouldn't that have the general
stuff in it for those versions? After all, wasn't that the mindset of
microsoft when they devleoped the office product line, to provide backward
compatitiblity? And isn't that one of the reasons we use interfaces?


Robert Jacobson said:
You can do that, but the references to Microsoft Word will then be
late-bound (of type "Object" instead of type "Word.Application.") This is
generally undesirable because you won't be able to use Intellisense in the
IDE, and increases the opportunities for bugs. There might be circumstances
where it's necessary, but it should generally be avoided.


CJ Taylor said:
Pardon my VB6 here, but using it purly for example.

Isn't the way Microsoft Office products are designed that if you just do a
createobject type issue with

CreateObject("Word.Application") it automatically returns the appropriate
version as per the regsitry defintion?

Could we use the same idea here? And only interop the Excel 7.0 (97)
Library to ensure 100% backwards compatiblity?

-CJ
8.0,
 
Do you mean the "Word.Application" interface? You'll only get that if your
project references a type library that defines the interface. Each version
of Word is backwards compatible to applications developed against earlier
versions of Word . (That's because later versions of the Word type library
are binary compatible with earlier versions of the libraries.)
Consequently, if your application references, e.g., the Word 8.0 type
library (Word 97), it will also work with Word 2000 (the Word 9.0 library),
Word XP (the Word 10.0 library), etc.

However, you won't get a strongly-typed interface if you just use
CreateObject, unless you cast the resulting reference from CreateObject to
type "Word.Application." In general, "Dim x as Object =
CreateObject("Word.Application")" is evil, while "Dim x as New
Word.Application" is good.


CJ Taylor said:
What about Word.IApplication interface... Shouldn't that have the general
stuff in it for those versions? After all, wasn't that the mindset of
microsoft when they devleoped the office product line, to provide backward
compatitiblity? And isn't that one of the reasons we use interfaces?


Robert Jacobson said:
You can do that, but the references to Microsoft Word will then be
late-bound (of type "Object" instead of type "Word.Application.") This is
generally undesirable because you won't be able to use Intellisense in the
IDE, and increases the opportunities for bugs. There might be circumstances
where it's necessary, but it should generally be avoided.
do
 
Robert Jacobson said:
Do you mean the "Word.Application" interface? You'll only get that if your
project references a type library that defines the interface. Each version
of Word is backwards compatible to applications developed against earlier
versions of Word . (That's because later versions of the Word type library
are binary compatible with earlier versions of the libraries.)
Consequently, if your application references, e.g., the Word 8.0 type
library (Word 97), it will also work with Word 2000 (the Word 9.0 library),
Word XP (the Word 10.0 library), etc.

However, you won't get a strongly-typed interface if you just use
CreateObject, unless you cast the resulting reference from CreateObject to
type "Word.Application." In general, "Dim x as Object =
CreateObject("Word.Application")" is evil, while "Dim x as New
Word.Application" is good.

I understand the difference between strong typing and weak typing or
latebinding vs. earlybinding, whatever you want to call it. But I'm trying
to help you solve your problem given you know nothing of what your user has
installed.

So, you want to use strongly typed so you can use intellisense, well fair
enough. Then reference your oldest library you have, which should guaruntee
your backwards compatibilty, but don't Dim X as new Word.Application,
because you create a constraint at that point.

Instead type it and use CreateObject. You still have your intellisense,
maybe not for all the features in XP, but then again, you could check to see
what versions of office are availible on the host machine.

I hope you understand I'm tyring to just give you a really simple solution
to the problem without having to do all sorts of version checks/go through
the mess you were going to go through earlier.

Good luck,
CJ
 
You don't need to use version checks on the host machine -- it doesn't
matter which version of Office the client has installed. If I develop an
application using the Word 97 type libraries on my development machine, it
will automatically work on a client machine that uses Word 2000, Word XP or
Word 2003.

It's a very simple solution -- things just got messy here because Scorpion
was trying to reference different versions of the type library, which was
unnecessary.


[Snip]
 
It's a very simple solution -- things just got messy here because Scorpion
was trying to reference different versions of the type library, which was
unnecessary.

I am sorry about that. I have an app that was suppose to go to a client that
did a lot of word automation and I needed to be sure what library I was
suppose to be in. I have heard many lines of thought on this issue.

For the record, I startd with 97 but found it limiting. I switched to 2000
library which was okay with the client.
 
¤ in my head......
¤
¤ I need my application to work with Office 97, 2000, XP and 2003 versions of
¤ MS Word and MS Excel.
¤
¤ IN order to acomplish this I have to install in different folders:
¤
¤ 1. remove my Office 2003
¤ 2. Install Office 97 Word and Excel
¤ 3. Install Office 2000 Word and Excel
¤ 4. Install Office XP Word and Excel
¤ 5. Reinstall my Office 2003
¤ 6. Open my project and add references for Word and Excel libraries 8?-11.
¤ The libraries will be there then right?
¤ 7. REbuild project.......
¤
¤ Last time I did something like this I spent weeks trying to fix the mess it
¤ turned into. I tried to install OFfice XP next to 2003 without taking 2003
¤ off.
¤
¤ I so much do not want to go through that again....

Develop against Office 97 and use late binding:

HOW TO: Use Visual Basic .NET for Binding for Office Automation Servers
http://support.microsoft.com/default.aspx?scid=kb;en-us;304661


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top