Solved

Microsoft.Office.Interop.Word.Document

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Install Problem 13 30
Help with adding data element is a specific row of an xml file using VB.NET 4 26
VB.net and sql server 4 35
RegEx with optional part 4 21
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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