Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

c#.net .docx File auslesen und den Inhalt samt Formatierung speichern

Empfohlene Antworten

Veröffentlicht

Sollte aus einem .docx File Text herauslesen und diesen speichern, inkl. Formattierung. Der Text wird nacher in einem anderen .docx Dokument an einem gewünschten Bookmark eingesetzt.

Wie kann ich den Text mit Formattierung auslesen?

bisherige Lösung, etwas "schroff" aber funktioniert auf ein bestimmtes Template bezogen ganz Okay:


            object nullobject = System.Reflection.Missing.Value;

            object start = 0;

            Word.Document wordDocument = Application.Documents.Open("pfad.docx", ref nullobject, ref nullobject

                                                                        , ref nullobject, ref nullobject, ref nullobject

                                                                        , ref nullobject, ref nullobject, ref nullobject

                                                                        , ref nullobject, ref nullobject, false

                                                                        , ref nullobject, ref nullobject, ref nullobject, ref nullobject

            );


            wordDocument.ActiveWindow.Selection.WholeStory();

            wordDocument.ActiveWindow.Selection.Copy();


            IDataObject data = Clipboard.GetDataObject();


            WordTemplate_inserttext.Globals.ThisDocument.richTextContentControl1.Text = data.GetData(DataFormats.Text).ToString();

            wordDocument.Close();

Setze ihn heir einfachmal in einem Dokument in eine Textbox, die Formatierung geht noch verloren, kannst du mir da vil. etwas helfen?

Ist es möglich beim GetData irgendwie nicht reinen Text zu kopieren sondern den Text wie er ist (formatiert)?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.