Solved

Microsoft.Office.Interop.Word.Document

Posted on 2011-09-16
3
1,364 Views
Last Modified: 2012-05-12
Error      28      Type 'Microsoft.Office.Interop.Word.Document' is not defined

when I got this error I stored a Microsoft.Office.Interop.Word.dll in a folder and added this dll as
reference to my project

then I no errors and created an exe file properly

but when I am executing that exe file I got the below error

 Unable to cast COM object of type 'Microsoft.Office.Interop.Word.DocumentClass' to interface type 'Microsoft.Office.Interop.Word._Document'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0002096B-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

what is this about .... may I know where did I made a mistake... or what should I change....



testcode.txt
0
Comment
Question by:shragi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 36552980
Please answer:
What VS version you are using?
What Word version you are targeting?
What Word version is installed in your development PC?

Microsoft.Office.Interop.Word.dll  are Office version dependent (For example version 12 only works with Word 2007)


0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36553081
Older dlls from before .NET needed to be registered in the Windows registry before you could call them. The Interop is not. That means that Word is not installed on the users computer, or that the .NET components where not installed when Word was installed, or that you are targeting an older version of Word than what is installed on the user computer (Word 2003 in your development environment while the user has only Word 2007 or 2010 installed on his).

You are not supposed to install Microsoft.Office.Interop.Word.dll in your project. It is supposed to be already installed on the user computer. Installing the .NET component is an installation option in all the Office applications.

The dll is only a bridge to Word, it does nothing in itself. Word must be installed on the computer, and the option for the .NET must be checked when the user installs Word. Doing so will register both Word and the interop in the registry of the user's computer, and your application should be able to find them.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 36553817
To prevent problems, you need to have the same version of Office on both your dev PC and the users' PC.

The best way to avoid this situation is to replace Office automation with a component like http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question