question

NallagondaLakshmiAdithya-3507 avatar image
0 Votes"
NallagondaLakshmiAdithya-3507 asked TimonYang-MSFT commented

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

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


[1]: /answers/storage/attachments/101305-docs-issue.png

dotnet-csharpoffice-deployment
docs-issue.png (131.1 KiB)
docs-issue-2.png (4.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NallagondaLakshmiAdithya-3507
May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.

0 Votes 0 ·

1 Answer

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.