Solved

Microsoft.Office.Interop.Word.Document

Posted on 2011-09-16
3
1,341 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AJAX Create / Update Not working MVC 5 67
Pdf not loading 2 41
How do I "share" on social sites? 2 39
Replace statements HTML with HTML IF 8 67
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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