Solved

Microsoft.Office.Interop.Word.Document

Posted on 2011-09-16
3
1,289 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
3 Comments
 
LVL 35

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 69

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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!
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now