I want to open one docx file and then convert it into pdf file in asp.net using Microsoft.Office.Interop.Word package.
This is my code written in asp button click event:
object fileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
Object missing = Type.Missing;
object saveName = strURL.Replace(".docx", ".pdf");
object openName = docPath + "\\T4.docx";
Microsoft.Office.Interop.Word.Application wdApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = wdApp.Documents.Open(openName,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
doc.SaveAs(saveName,fileFormat,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
doc.Close(ref missing, ref missing, ref missing);
But it has some trouble on wdApp.Documents.Open() line when executing.
Browser symbol seems like loading always.
I don’t know what is the cause of reason for this error.
Microsoft doesn’t support automation of Office applications in a server environment and this KB article explains some of the potential problems that can occur if you try it.
I suggest you look for a third-party component, such as Aspose.