thefarm
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-0 0000000004 6} from the IClassFactory failed due to the following error: 8001010a.
Here is my code behind:
Any help is much appreciated.!
Ben
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-0
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
Any help is much appreciated.!
Ben
Does the client PC have Microsoft Word or Office installed?
ASKER
Yes, both client and server are mussing office 2007.
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?
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?
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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! the problem was dialog boxes killing my code!
Appreciate the help!
Appreciate the help!
ASKER
Here is the line I added to fix my code!
objWordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone