Hi
I am trying to convert doc to pdf using the following code
public void ConvertPdf()
{
object sFilename = "Report5.doc";
object FromLocation = Server.MapPath("~/Form5/" + sFilename.ToString());
string ChangeExtension = sFilename.ToString().Replace(".doc", ".pdf");
object ToLocation = Server.MapPath("~/Form5PDF/" + ChangeExtension);
//string ConvertResult = word2pdf.Word2PdfCOnversion(FromLocation, ToLocation);
Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
object oMissing = System.Reflection.Missing.Value;
word.Visible = false;
word.ScreenUpdating = false;
Document doc = word.Documents.Open(ref FromLocation, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
doc.Activate();
object fileFormat = WdSaveFormat.wdFormatPDF;
doc.SaveAs(ref FromLocation,
ref fileFormat, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
doc = null;
}
In that in the line doc.saveas, i am facing an error saying command file.
Can any one give me an error about how to solve this.
I am using Microsoft Visual Web Developer 2008 Express.