Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Microsoft.Office.Interop.Word.Document

Posted on 2011-09-16
3
Medium Priority
?
1,383 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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