public static void CreateWordDocument(object filename, object SaveAs, Krc krc) { Word.Application wordApp = new Word.Application(); object missing = Missing.Value; Word.Document myWordDoc = null; if (File.Exists((string)filename)) { object readOnly = false; object isVisible = false; wordApp.Visible = false; myWordDoc = wordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Activate(); //find and replace FindAndReplace(wordApp, "<KrSerialNo>", krc.SerialNo); FindAndReplace(wordApp, "<KrType>", krc.Type); FindAndReplace(wordApp, "<KrName>", krc.Name); FindAndReplace(wordApp, "<KRCVersion>", krc.Version); FindAndReplace(wordApp, "<Tech1>", krc.Tech); //FindAndReplace(wordApp, "<Tech2>", krc.Tech[1]); //FindAndReplace(wordApp, "<Tech3>", krc.Tech[2]); //FindAndReplace(wordApp, "<Tech4>", krc.Tech[3]); //FindAndReplace(wordApp, "<Tech5>", krc.Tech[4]); FindAndReplace(wordApp, "<LoadData1>", krc.LoadData[0]); FindAndReplace(wordApp, "<LoadData2>", krc.LoadData[1]); FindAndReplace(wordApp, "<LoadData3>", krc.LoadData[2]); FindAndReplace(wordApp, "<LoadData4>", krc.LoadData[3]); //FindAndReplace(wordApp, "<LoadData5>", krc.LoadData[4]); FindAndReplace(wordApp, "<MaintenanceDate>", System.DateTime.Now.Date); } //Save as myWordDoc.SaveAs2(ref SaveAs, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Close(); wordApp.Quit(); }