Hi Everyone,
I am struggling since last 3 days and i googled every where to solve this issue..
public bool SaveDocument(object objWordOutputPath, string strOutputFolder)
{
try
{
object objMissing = System.Reflection.Missing.Value;
object objOutputFileName = objWordDoc.FullName.Replace(".doc", ".pdf");
object objFileFormat = WdSaveFormat.wdFormatPDF;
objWordDoc.SaveAs(ref objOutputFileName,
ref objFileFormat, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing);
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
return true;
}
catch (Exception ex)
{
CloseDocument();
Logger.LogFormat("Error mesaage:-->" + ex.Message);
Logger.LogFormat("Error mesaage:-->" + ex.StackTrace);
objWordDoc = null;
return false;
}
}
As i written code to generate pdf file form word document its working fine in my local desktop and i generated an ".msi" for this code snippet.
I had installed it on Windows server 2008 R2 when i run the ".exe" i got an error saying that...
("Command Failed" and "at Microsoft.Office.Interop.Word.DocumentClass.SaveAs(Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePassword, Object& ReadOnlyRecommended, Object& EmbedTrueTypeFonts, Object& SaveNativePictureFormat, Object& SaveFormsData, Object& SaveAsAOCELetter, Object& Encoding, Object& InsertLineBreaks, Object& AllowSubstitutions, Object& LineEnding, Object& AddBiDiMarks)")
Office version 2007, Visaul Studio 2010 and Windows server 2008 R2.
Could you please help me out to solve this issue....
Regards,
Dilip.