private void WriteWord() { file = Application.StartupPath + "\\Two.docx"; wc = new WordClass(file); wc.OpenWordDoc(); st = ""; if (richTextBox1.InvokeRequired) { richTextBox1.Invoke(new Action(() => k = richTextBox1.Text.Length)); richTextBox1.Invoke(new Action(() => txt = richTextBox1.Text)); } else { k = richTextBox1.Text.Length; txt = richTextBox1.Text; } for (int i = 0; i < k; i++) { if (txt[i].Equals('\n')) { wc.word_doc.Paragraphs.Add((object)st); st = ""; } else { st += txt[i]; } } wc.CloseWordDoc(); }
private void TaskMethod() { SettingsControls.EnableOff(richTextBox1); wc = new WordClass(file); wc.OpenWordDoc(); ReadWord(); wc.CloseWordDoc(); WriteWord(); SettingsControls.EnableOn(richTextBox1); SettingsControls.VisibleOn(button1); SettingsControls.VisibleOn(button2); SettingsControls.VisibleOn(button3); }