.NET Programming
--
Questions
--
Followers
Top Experts
(Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
I am trying to automate Word from a VB.net application but keep getting the error:
"Unable to cast COM object of type 'Microsoft.Office.Interop. Word.Appli cationClas s' to interface type 'Microsoft.Office.Interop. Word._Appl ication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000- 0000000000 46}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) ."
I ran RegAsm to register Office.dll, Microsoft.Vbe.Interop.dll and Microsoft.Office.Interop.W ord.dll successfully.
However, I continue to get this error when oWord.Visible = True attempts to execute.
"Unable to cast COM object of type 'Microsoft.Office.Interop.
I ran RegAsm to register Office.dll, Microsoft.Vbe.Interop.dll and Microsoft.Office.Interop.W
However, I continue to get this error when oWord.Visible = True attempts to execute.
Imports Word = Microsoft.Office.Interop.Word
Imports System.Runtime.InteropServices
Private Sub OpenWordDoc
Dim oWord As Word.Application
Dim wDoc As Word.Document
Dim para1 As Word.Paragraph
Dim strResult As String
oWord = CreateObject("Word.Application")
oWord.Visible = True
wDoc = oWord.Documents.Add
para1 = wDoc.Content.Paragraphs.Add
para1.Range.Text = RepairCommentsTextBox.Text
'para1 = wDoc.Content.Paragraphs.Add()
'para1.Range.Text = RepairCommentsTextBox.Text
'para1.Range.InsertParagraphAfter()
wDoc.CheckSpelling()
strResult = Microsoft.VisualBasic.Left(wDoc.Content.Text, Len(wDoc.Content) - 1)
If Not RepairCommentsTextBox.Text = strResult Then
RepairCommentsTextBox.Text = strResult
End If
End Sub
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
You did point out a problem that I had not gotten to just yet. The problem causing the error was solved by removing a conflicting Interop assembly. The following link was helpful in getting to the problem: http://msdn.microsoft.com/en-us/library/aa159923(office.11).aspx
that plus advice from a Word Automation Expert.
that plus advice from a Word Automation Expert.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
.NET Programming
--
Questions
--
Followers
Top Experts
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.