Unable to copy one document content (xhtml) to another document (xhtml) using openxml c# after Office 365 latest update (version 2008) .

Nallagonda Lakshmi Adithya 1 Reputation point
2021-06-01T07:17:10.06+00:00

I have a requirement where in I have to copy all the data in one word document (text, images and everything else) to another document.

I save the data from one file in ".mhtml" & then try to insert it in to another ".docx" file. I have been using "altchunk" for pasting xhtml data from one ".docx" file and inserting it into another ".docx" file for almost 3 years now.

Recently there's been an update in Office 365 recently and after that latest updated version (v 2008), the altchunk is not copying the images from one document to another. Only the text is getting copied. I couldn't find any proper solution to this. Kindly help if you have any suggestions. Thanks in advance!
101305-docs-issue.png

101361-docs-issue-2.png

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,852 questions
Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,122 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,591 Reputation points
    2021-06-02T02:13:04.537+00:00

    Is it possible to use other packages such as Microsoft.Office.Interop.Word?

    The following code worked well for me in Office 2016, you can try if it works for Office 365.

            public static void InteropExcel()   
            {  
                var application = new Microsoft.Office.Interop.Word.Application();  
                var sourceDoc = application.Documents.Open(@"D:\test\word\13.docx");  
      
                sourceDoc.ActiveWindow.Selection.WholeStory();  
                sourceDoc.ActiveWindow.Selection.Copy();  
      
                var destDocument = application.Documents.Open(@"D:\test\word\1.docx");  
                destDocument.ActiveWindow.Selection.Paste();  
      
                sourceDoc.Close();  
                destDocument.Close();  
      
                application.Quit();  
            }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.