office word and c#

M

m.a

can I detect if word is installed at the user computer and if yes, which
version?

How can I write code to interact with a different version of word which is
not installed on my computer?

I can think of a solution such as (dummy code snippets)



object word =createobj("word.appliaction);

if (word != null) // word is installed

{

string version= word.GetVersion();

switch (version)

{

case "2000":

work_with_word_2000();

break;

case "2003":

word_with_word_2003();

break;

}

}



But how can I write this code in c#?



Any help is very appreciating.



Regards
 
J

jp2msft

I did something similar for Office Outlook.

First, you'll probably need to drop a reference into your project. My
particular case used:
Microsoft.Office.Core, and
Outlook
Yours (Office Word) would differ somewhat.

In your includes, you'll need something like:
using Outlook = Microsoft.Office.Interop.Outlook;

I apologize for not mapping it out exactly, but I don't know exactly. I just
know what I did to get access to the Outlook application.

Other options might be looking at the registry keys or in the User's
Applications folder (C:\Documents and Settings\User9\Application
Data\Microsoft\Office).

Hope this information does some good!
 
C

Cindy M.

Hi M.a,
can I detect if word is installed at the user computer and if yes, which
version?
Inspect the Registry key HKCR\Word.Application

The CurVer key gives the current version installed (or, it multiple
versions are installed, the one that's considered to be "current" - usually
the newest). The CLSID key provides the GUID. If you search the GUID in the
Registry for its key you'll turn up more information, such as the *.exe
file location.

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