none
vb.net open word document throws error RRS feed

  • Question

  • Just trying to build a VB.Net win form app that opens existing word documents. Get same error in VS2012 & VS2010. The error is:

    An error occurred creating the form. See Exception.InnerException for details.  The error is: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Word.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

    Add references to: Office and Word Object Library 12.0


    bdpb

    Wednesday, June 26, 2013 6:50 PM

Answers

All replies

  • Just trying to build a VB.Net win form app that opens existing word documents. Get same error in VS2012 & VS2010. The error is:

    An error occurred creating the form. See Exception.InnerException for details.  The error is: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Word.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

    Add references to: Office and Word Object Library 12.0

    Form code:

    Imports Microsoft.Office.Interop.Word
    Public Class Form1

        Dim app As New Application

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

            app.Documents.Open("C:\temp\Doc1.docx")
        End Sub
    End Class


    bdpb



    bdpb

    Wednesday, June 26, 2013 6:51 PM
  • Hi Bdpb,

    Thank you for posting in the MSDN Forum.

    Do you have Office installed on your computer? What's the version number?

    I look forward to your reply.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 27, 2013 8:37 AM
    Moderator
  • I believe that is the problem Quist, I have multiple installations. Under references it shows 12, 14 and 15 for MS Office but for Word Object Library I only see 12.0 I have some Office 2007, 2010 and a little from Office 2013 I think.

    bdpb

    Thursday, June 27, 2013 10:28 AM
  • Hi Bdpb,

    Thank you for your last reply.

    For my part, I would not have multiple versions' Office installed on my dev-machine.

    Here's a KB article in regard to this kind issue: Office automation when multiple versions of Office are installed.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by JPL_GDoL Thursday, June 27, 2013 5:19 PM
    Thursday, June 27, 2013 12:42 PM
    Moderator
  • You nailed Quist!

    That is the exact issue I have run into. I will unload the old office versions and make sure I have a clean install. Now that I see InfoForms 2013 has nothing the 2010 didn't have I can get rid of it as well and just stick with 2010 for now.

    Thanks for your assistance,

    Bdpb


    bdpb

    Thursday, June 27, 2013 5:19 PM