Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:46:31+00:00 2026-05-26T18:46:31+00:00

I have the following problem: Text needs to be copied from 1 wordprocessing document

  • 0

I have the following problem:

Text needs to be copied from 1 wordprocessing document to another wordprocessing document. The source document is not always accessible when inserting the text in the target part. The text is serialized and retrieved later on.

They way I currently do this is by copying the paragraphs elements and then appending them into the other document. This works fine unless bullets are involved. The bullets are not copied from the source to the target document.

Here is some example code:

Public Sub SerializeParagraphsBetweenBookmark(ByVal stream As Stream)
    Dim wordDoc = WordprocessingDocument.Open(_fileLocation, True)
    Dim paragraphsFromBookmarks As IEnumerable(Of Paragraph)
    Using (wordDoc)
        paragraphsFromBookmarks = GetAllParagraphFromBookmarks(wordDoc)
    End Using
    SerializeParagraphsToFile(paragraphsFromBookmarks, stream)
End Sub

Private Sub SerializeParagraphsToFile(ByVal paragraphsFromBookmarks As IEnumerable(Of Paragraph), stream As Stream)
    ' the IEnumerable of paragraphs must be converted to an IEnumerable of strings before it can be converted
    Dim serializableIEnumerable = paragraphsFromBookmarks.Select(Function(x) x.OuterXml).ToList()
    Dim binSerializer As New BinaryFormatter()
    binSerializer.Serialize(stream, serializableIEnumerable)
End Sub

Then when I retrieve them, I add them to the target file like so:

Public Sub InsertParagraphsInDocument(paragraphs As IEnumerable(Of Paragraph))
    Dim wordDoc = WordprocessingDocument.Open(_fileLocation, True)
    Using (wordDoc)
        Dim rootElement = wordDoc.MainDocumentPart.RootElement
        Dim bookmark = rootElement.Descendants(Of BookmarkStart).FirstOrDefault(Function(x) x.Name.Value.Equals(_pasteBookmark))
        Dim paragraphsList = paragraphs.ToList()
        For i As Integer = paragraphsList.Count - 1 To 0 Step -1
            bookmark.Parent.InsertAfterSelf(paragraphsList(i))
        Next
    End Using
End Sub

The code is nothing fancy and any improvement suggestions are welcome.

I know that bullets are stored in the NumberingDefinitionsPart of the MainDocument part but my problem is how do I know which AbstractNum and NumberingInstance to insert in this NumberingDefinitionsPart?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:46:32+00:00Added an answer on May 26, 2026 at 6:46 pm

    I found the answer myself, it seems I had to synchronize the numbering definition part between the two files.

    I wrote a tool that does this so if anyone is interested, check it out: http://www.lucbos.net/2011/11/wordprocessing-serialization-move.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from my previous question [link text][1] , I have a new problem.
I have the following problem: I got a view with two text fields and
I have the following problem with Tikz/Latex: I have some nodes that contain text.
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem that needs to be solved in a MySQL query:
I am self-learning C++ from a text book and I have a problem to
I have a following code: $(document).ready(function() { $('a[rel]').each(function() { $(this).qtip( { content: { text:
I have following problem: I have built a tabbar application with 4 tabs. I
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
I have the following problem using subversion: I'm currently working on the trunk of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.