TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gunti Dilip
NA
54
103.9k
Exception occurred while generating pdf from word document.
Sep 2 2013 1:02 PM
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.
Reply
Answers (
3
)
Copy Xml Node to another XML file
Search function with LINQ