1.Check file permissions for file/ drive.
2.make sure there is sufficient memory and disk space.
private void GenerateApplication()
{
object readOnly = true;
object repair = false;
object bookMarkName = "applicantName";
object bookMarkCompany = "firmName";
object bookMarkPost = "postName";
fielName = @"C:\Documents and Settings\All Users\Desktop\OperateWordFromC#.dotx";
objDoc = wordApp.Documents.Open(ref fielName, ref missingValuesValues, ref readOnly, ref missingValuesValues, ref missingValuesValues,
ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues,
ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref repair, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues);
objDoc.Activate();
objDoc.Bookmarks.get_Item(ref bookMarkName).Range.Text = txtApplicantName.Text;
objDoc.Bookmarks.get_Item(ref bookMarkCompany).Range.Text = txtAppliedCompany.Text;
objDoc.Bookmarks.get_Item(ref bookMarkPost).Range.Text = txtAppliedPost.Text;
string outputFile = @"C:\Documents and Settings\All Users\Desktop\ApplicationOf-" + txtApplicantName.Text + ".docx";
bookMarkName = null;
bookMarkCompany = null;
bookMarkPost = null;
Object objSaveAsFile = outputFile;
Object objFileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;
wordApp.ActiveDocument.SaveAs(ref objSaveAsFile, ref repair, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues,
ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues,
ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues, ref missingValuesValues);
wordApp.Visible = true;
}
Replies
Know the answer? Post it — somebody with the same question will find it here.