views:

1442

answers:

6

An application currently in development has the requirements for using MS Word to perform spell check on certain textareas within the application.

I currently have Office 2007 (which is the Office 12 com objects).

My question is, if I add in the Office 12 objects what will happen on boxes which have Office 2003? This is in regards to both other development boxes as well as the end users.

Am I correct in believing that the end result will be that the spell capabilities will not be available for those users? And if I used an Office 11 object would that mean that the users would be unable to perform the spellchecks if they have Office 07 installed?

A: 

I am guessing here, but if it is as you can't use the 2007 PIA (Primary Interop Assembly) with a 2003 installation, you could try accessing the PIA via reflection as I would guess the calls you want won't change between the two, and then it won't matter - you'll use whichever is installed. If you are installing the PIA as well, you can then either get the user to tell you which they have, or be a little more clever and just try 2007 and if it fails, try 2003.

Like I said, I'm guessing here but it might be worth a try.

EDIT: I found this link about Office PIA's. This refers to Excel but actually covers Office in general. I don't envy the task you have. Looks like you'll need to detect the PIA (which may or may not be installed) and act accordingly. Sounds like a job for reflection to me.

Jeff Yates
+1  A: 

We gave up on trying to use a dependency on Word, as both have differing versions installed or no Office installation at all! Instead opting for NetSpell.

Mark Glorie
A: 

Newer versions of Office will maintain most if not all compatibility with older versions of COM objects. Meaning if you want to program against Office 2003 and 2007 you will need to use Office 11 COM objects as a dependency as they were the newest available when 2003 was released. As long as you verify that the methods you need exist both versions of COM objects you should have no problems as long as you use the older COM objects.

Unfortunately, although I have used this solution for my own work, I have not tested it with Spell Check. In the end make sure that you test your code with all version of Office that you wish to integrate with.

A: 

My gut reaction to this question, is to simply suggest you go another route. Try using a 3rd party spell-check control. They are relatively inexpensive (and you may find some free controls). At least that way you can control the version of the control included with your app and be able to rely on it's functionality. Quite frankly, I'm surprised this library isn't built into Windows already. Sure it's complicated with all of the languages Windows supports, but these days it's similar to copy/paste in terms of user expectations.

jwalkerjr
A: 

Hey there. This is my first post here. I'm in the midst of trying to implement spell check on FCK edit boxes on aspx pages as well. Out of the box FCK's spell check uses IESpell, which my bosses would rather not license. So...

I'm going the same route you were at the time you posed this question.

Right now I'm using the Office 12 COM objects and it works fine (albeit very roughly) on my dev machine, running with VS's IIS thing (F5).

I put it out to DEV and of course it blew up - neither the PIAs, nor Office are installed on the webserver.

From reading your question, I begin to fear I may be totally misunderstanding what I'm doing - if do something like this: http://pastebin.com/m668b7034

but of course handle the mark as misspelled and suggest clientside (I'm thinking some CSS and injected JS), what the users have clientside - Office 2003, 2007, none at all, doesn't matter, does it? I'd be using the Word COMs server side, and checking it all during postback. Isn't that correct? Or is this just me being a total nubcaeks?

Thanks.

PS - this site seems pretty keen.

Office COM objects are not supported in a WEB FORMS environment. My discussion here is for a WINDOWS FORMS application. You'd be happier checking into the NETSPELL object linked in Mark's Post (http://stackoverflow.com/questions/159799/vbnet-automating-ms-word-for-spell-check-capabilities#160966)
Stephen Wrighton
A: 

You can actually package both the office11 and office12 interops needed to work in BOTH versions. It takes some minor work but I managed to do it. I do a check in the registry to see which interop to call and then executes the spell checking with the correct version. It even goes so far as to check if you have Word installed and throws an error alert that you can't spell check without having Word. We're tied to using Word due to the medical dictionary that's tied into Office we're required to use.

Do a search on interop or Com wrappers and I think you'll find you can use both fairly easily.