Interop Word – SaveAs Command Failed Error-Collection of common programming errors
Using
MS Office 2007
VS 2010 – Pointing frame work to 3.5
Windows 7
referenced NET Component Word 12.0 dll in C# code
——————————————————-
I wrote a console application to create PDF ..when I am running this application from my user (like double click) it is creating PDFs
But when I configured the same console application as Windoows Service (run as User (me), as SYSTEM, As Local same result)..I am getting exception from SaveAs command
Can any body help me? Obviously it is missing some thing when the application is running as a Windows Service. What it is?
Some dll? DCOM settings? another security? what it is I can’t think straungt? Help me!!!
Exception:
System.Runtime.InteropServices.COMException (0x800A1066): Command failed 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)
at SnapshotReportGenerator.reportWrkThread.createReports(ArrayList ScreenData, String newStorePath, Int64 jobId, Int64 recId, String ifileName, Int64 queueId) in C:\C#\SnapshotReportGenerator\SnapshotReportGenerator\reportWrkThread.cs:line 224
Code:
object fileFormat = Word.WdSaveFormat.wdFormatPDF;
oDoc.SaveAs(ref fileName, 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);