Unable to create Word 2003 document using Automation after deinstallation MS Office 2007

V

Vyacheslav Akeyev

Hi all,
My web application is using the library Microsoft.Office.Interop.Word.dll
for MS
Office 2003.
MS Office 2007 was installed onto the server the first, afterwardsMS Office
2003 was
installed , than MS Office 2007 was uninstalled. Than Primary
Interop Assemblies for Office 2003 were installed. When the program
code does the tries to run Microsoft Word 2003 exception with message
"Unable to cast COM object of type
'Microsoft.Office.Interop.Word.ApplicationClass' to interface type
'Microsoft.Office.Interop.Word._Application'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{00020970-0000-0000-C000-000000000046}' failed due to the following error:
could not be found. (Exception from HRESULT: 0x80030002
(STG_E_FILENOTFOUND))." appeares. The server works under Misrosoft Windows
Server 2003.
Program code:
public TemplateDOC(string templateName)

{

_Application tempw;

try

{

tempw = new Application();


CultureInfo culture = Thread.CurrentThread.CurrentCulture;

Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");

word = new Application();//ÚÁÐÕÓËÁÅÍ Word


word.DisplayAlerts = WdAlertLevel.wdAlertsNone;

Thread.CurrentThread.CurrentCulture = culture;

object saveChanges = WdSaveOptions.wdDoNotSaveChanges;

tempw.Quit(ref saveChanges, ref missing, ref missing);

Marshal.ReleaseComObject(tempw);

tempw = null;

}

catch(Exception ex)

{



throw new Exception(ex.Message, ex);

}

object templName;

if (templateName == string.Empty)

{

templName = missing;

}

else

{

templName = templateName;

}

try

{

//ÓÏÚÄÁ£Í ÎÏ×ÙÊ ÄÏËÕÍÅÎÔ Ó ÛÁÂÌÏÎÏÍ

word.Documents.Add(ref templName, ref missing, ref missing, ref missing);

}

catch (Exception ex)

{

throw new Exception("Unable to open file: " + templateName, ex);

}

}

Could you help me to solve this problem.

Thanks in advance.

Vyacheslav Akeyev
 
C

Cindy M.

Hi Vyacheslav,
My web application is using the library Microsoft.Office.Interop.Word.dll
for MS
Office 2003.
MS Office 2007 was installed onto the server the first, afterwardsMS Office
2003 was
installed , than MS Office 2007 was uninstalled. Than Primary
Interop Assemblies for Office 2003 were installed. When the program
code does the tries to run Microsoft Word 2003 exception
I believe under this scenario the reference to the Office 2007 PIAs is still
listed in the Registry, so your application will be redirected to the
incorrect set of PIAs. Thus the error.

See if this discussion helps
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/08f13e9d-895c-4102-
b6d9-e327af8cf8c0/

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 :)
 
V

Vyacheslav Akeyev

Cindy M. said:
Hi Vyacheslav,

I believe under this scenario the reference to the Office 2007 PIAs is
still
listed in the Registry, so your application will be redirected to the
incorrect set of PIAs. Thus the error.

See if this discussion helps
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/08f13e9d-895c-4102-
b6d9-e327af8cf8c0/

Cindy Meister

Hi Sindy,
Thanks a lot for your answer.
I have red the topic you speciefed on the Microsoft Forum. I have looked the
registry key speciefed in this post - it exists and the reference onto the
msword.olb is correct but it's unable to run MS Word yet. :(
What should I do more again to find the solution of this problem?

Thanks in advance.
 

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