Link to home
Start Free TrialLog in
Avatar of thefarm
thefarmFlag for United States of America

asked on

Error Creating an instance of the COM component in ASP.Net

I am trying to compare an uploaded word document with another document on my server using word's "track changes" feature.

When i run the application on the server locally, it works great. But when i try to run the application from a client PC, i get the following error:

Creating an instance of the COM component with CLSID {00020906-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 8001010a.

Here is my code behind:

Imports Microsoft.Office.Interop

Partial Public Class test
    Inherits System.Web.UI.Page


    Protected Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click

        If FileUpload1.HasFile <> Nothing Then
            FileUpload1.PostedFile.SaveAs("C:\inetpub\wwwroot\TFIFamilyServices\documents\edit\1.docx")
        End If

        Dim objWordApp As New Word.Application

        objWordApp.Visible = False

        Dim originalDocument As New Word.Document

        Dim changedDocument As New Word.Document

        originalDocument = objWordApp.Documents.Open("C:\inetpub\wwwroot\TFIFamilyServices\documents\live\test.docx")

        changedDocument = objWordApp.Documents.Open("C:\inetpub\wwwroot\TFIFamilyServices\documents\edit\1.docx")

        objWordApp.CompareDocuments(originalDocument, changedDocument, Word.WdCompareDestination.wdCompareDestinationRevised, Word.WdGranularity.wdGranularityCharLevel, True, True, True, True, True, True, True, True, False, True, "Cordinator", True)

        changedDocument.ExportAsFixedFormat("C:\inetpub\wwwroot\TFIFamilyServices\documents\edit\1.pdf", Word.WdExportFormat.wdExportFormatPDF, False, Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Word.WdExportRange.wdExportAllDocument, , , Word.WdExportItem.wdExportDocumentWithMarkup, False, False, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks)

        changedDocument.Close(Word.WdSaveOptions.wdSaveChanges)

        originalDocument.Close(Word.WdSaveOptions.wdDoNotSaveChanges)

        objWordApp.Quit()
        objWordApp = Nothing

    End Sub

End Class

Open in new window


Any help is much appreciated.!
Ben
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Does the client PC have Microsoft Word or Office installed?
Avatar of thefarm

ASKER

Yes, both client and server are mussing office 2007.
Avatar of thefarm

ASKER

sorry for the typo..."running office 2007"
Hi there

To clarify:

When you say the application runs correctly on the server, do you mean that you can open Word interactively and compare the two documents, or that when you call your code from the server the code works?

When you say you try running the application from a client PC, do you mean when you run your ASP.NET code through a browser?

There are some changes that you will need to make to your code in order for Word to unload from memory properly once it has completed.  Also you should be aware that if Word displays a dialog box for any reason, your code will not complete and an instance of Word will remain in memory.

Have you considered 3rd party tools that you could automate to compare the two documents?
Avatar of thefarm

ASKER

Hello Hairbrush:

Thanks for the response...

The code I provided works when I run the application on the server.

Yes, when I say I am running on the client I am running through the browser on a machine other than the server. ex.http://192.168.5.4/index.aspx (192.168.5.4 is the server)

If you have any suggestions on code improvements I would appreciate it.

Also, do you have any third party solutions you could suggest???

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Hairbrush
Hairbrush
Flag of Jersey image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thefarm

ASKER

Thanks!  the problem was dialog boxes killing my code!

Appreciate the help!
Avatar of thefarm

ASKER

Here is the line I added to fix my code!

 objWordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone

Open in new window