objMailContent.Save(strTempPath + GroupID + "\" + StrDocFileName);
var wordApp = new Microsoft.Office.Interop.Word.Application(); var wordDocument = wordApp.Documents.Open(strTempPath + GroupID + "\" + StrDocFileName);
wordDocument.ExportAsFixedFormat(strAttachmentPath + StrNewFileName, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
wordDocument.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNoteChanges, Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat, false); //Close document
wordApp.Quit(); //Important: When you forget this Word keeps running in the background
bIsDocFile = true;
The above is the code for converting a .doc or .docx document to pdf and saves it on to my drive normally.
The above code is a part of my application which uses REBEX.
The above code works fine when I try to run my application through scheduler when i select an option "Run only when User is logged on" when i select option "Run whether user is logged on or not" the above code gives an error of "Object not set to reference".