Aşağıdaki kod ile Word dosyalarını richtextbox'a import ediyorum.
Benim yapmak istediğim import ettikten sonra richtetbox'a eklenen yazılardan sonra ilk satırdaki yazıyı textbox1'eklemek. (sadece ilk satırdaki enter'e kadar)
Düzenleyebilir misiniz?
`void ImportWord()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "Doc files (*.docx)|*.docx|All files (*.*)|*.*";
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
label4.Text = openFileDialog.FileName;
bekleyin.Text = "YÜKLENİYOR BEKLEYİNİZ.";
Microsoft.Office.Interop.Word.Application wordObject = new Microsoft.Office.Interop.Word.Application();
object File = label4.Text;
object nullobject = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application wordobject = new Microsoft.Office.Interop.Word.Application();
wordobject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; Microsoft.Office.Interop.Word._Document docs = wordObject.Documents.Open(ref File, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject, ref nullobject); docs.ActiveWindow.Selection.WholeStory();
docs.ActiveWindow.Selection.Copy();
this.txtmetin.Paste();
docs.Close(ref nullobject, ref nullobject, ref nullobject);
wordobject.Quit(ref nullobject, ref nullobject, ref nullobject);
bekleyin.Text = "";
}
}`