I am working on convert .doc to .html. code works perfectly when i right click on the .aspx page and click on "View in browser" but the same code is not working when i use link or url like "http://10.9.39.65:8888"
i tried reinstalling the Microsoft office 2003 but still not working even try with different code still no success.
below is my code :
string folder_to_save_in = @"C:\Inetpub\wwwroot\Pdf to HTML\Attachments\";
string filePath = folder_to_save_in + FileUpload1.FileName; // This bit does the actual file upload:
FileUpload1.SaveAs(filePath);
//Here we set up a WOrd Application...
Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new Microsoft.Office.Interop.Word.ApplicationClass();
// Opening a Word doc requires many parameters, but we leave most of them blank...
object o_nullobject = System.Reflection.Missing.Value;
object o_filePath = filePath;
Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref o_filePath, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject);
// Here we save it in html format...
// This assumes it was called "something.doc"
string newfilename = folder_to_save_in + FileUpload1.FileName.Replace(".doc", ".html");
object o_newfilename = newfilename;
object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
object o_endings = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
// Once again, we leave many of the parameters blank.
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/womthSaveAs1_HV05213080.asp
// for full list of parameters.
wordApplication.Activedocument.SaveAs(ref o_newfilename, ref o_format, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_encoding, ref o_nullobject, ref o_nullobject, ref o_endings, ref o_nullobject);
// Report success... Label1.Text = "Uploaded successfully!";
// Finally, close original...
doc.Close(ref o_nullobject, ref o_nullobject, ref o_nullobject);
string path = newfilename;
Response.Write("<script language='javascript'>alert('The file has been successfully uploaded !!!')</script>");
}
if (con != null)
{
con.Close();
}
con = null;
gdb = null;
cmd = null;
}
I am getting the below error :
System.Runtime.InteropServices.COMException (0x800A1066): Command failed at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform) at upload.Button1_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Pdf to HTML\upload.aspx.cs:line 59
This post has been edited by tlhIn`toq: 20 June 2012 - 02:45 PM
Reason for edit:: ending code tag as a slash [/code]

New Topic/Question
Reply



MultiQuote




|