COMException using Interop for Word

  • Thread starter Thread starter jochy2
  • Start date Start date
J

jochy2

Guest
Hello all, can someone please help me out, I am currently working on a web project which requires the creation of Word Document, Edition to the same and access to HeaderFooter section. Ive installed the required reference to the Office library and apparently all is ok as I get no error while calling references or properties in VS 2013, however, when I save, upload and run tests to create a Word Document, I get the following error:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Empleese_V2._0._0._1.WordDocC.createWordDoc(String fName, Boolean IsHeaderText, String docHeaderText, Int32 docHeaderSize, Boolean isImage, String img) in ....WordDocC.vb:line 15 Can someone please help me determine what my problem is following is the test code:

Try If File.Exists(HttpContext.Current.Server.MapPath("~/Inicio/Account/Members/Utilidades/Documents/" + fName + ".docx")) Then File.Delete(HttpContext.Current.Server.MapPath("~/Inicio/Account/Members/Utilidades/Documents/" + fName + ".docx")) Else Dim wordApp As New Application() Dim fileName As Object = HttpContext.Current.Server.MapPath("~/Inicio/Account/Members/Utilidades/Documents/" + fName + ".docx") Dim missing As Object = System.Reflection.Missing.Value Dim wordDoc As Document = wordApp.Documents.Add(missing, missing, missing, missing) wordDoc.Activate() wordDoc.Content.InsertBefore("This is Word document created in ASP.NET") wordDoc.Content.InsertParagraphAfter() wordDoc.SaveAs(fileName) wordApp.Application.Quit(missing, missing, missing) End If Catch ex As Exception errorHandler(DateTime.Now(), ex.ToString()) HttpContext.Current.Response.Redirect("~/Inicio/FE_Error.aspx") End Try

Continue reading...
 
Back
Top