Extract embedded file from Word document

Hi,
Looking at the WOLEObject, I see that we can get the native bytes of the embedded file.
How do I extract the embedded file?

I am using the Syncfusion.DocIO.AspNet.Mvc5 version 17.4.055 NuGet package and the language is C#.

Thanks,
Rohit

4 Replies

MR Manikandan Ravichandran Syncfusion Team May 15, 2020 04:23 PM UTC

Hi Rohit,

Thank you for contacting Syncfusion support .

We have prepared the sample to extract the OLEObject from the word document and save as a separate file
with their native file format. It can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/154281/ze/F154281-590278427

In the sample we have done the following things,
1.Opens an existing DOCX format Word document.
2.Gets OLE object from the Word document.
3.Saves the embedded OLE object as separate document in a location.
4.Saves the Word document and closes the document.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran
 



RJ Rohit J May 17, 2020 11:23 AM UTC

Hi,

Thank you. Now I am able to extract the OLE files.
However, I'm looking for a way to remove the OLE file from the Word document and replace it with some text.

paragraph.ChildEntities.Remove(entity)

is not working.  Instead, some text like "EMBED AcroExch.Document.p7" is added to the document just above the embedded PDF.

What am I doing wrong and how do I achieve what I want to do?

Regards,
Rohit


MR Manikandan Ravichandran Syncfusion Team May 18, 2020 11:30 AM UTC

Hi Rohit,

Thank you for your update.

We have prepared the sample application to remove the OLEObject from the document and it can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/154281/ze/F154281_Modified-976274908

In this sample we have done the following.
1. Load the template document which contains OLEObjects.
2. Find the OLEObject in the document
3. Remove the OLEObject and its child elements like Field Separator and Field End.
4. Save and close the word document.

Please let us know if you have any further questions.

Regards,
Manikandan Ravichandran
 



RJ Rohit J May 25, 2020 07:01 PM UTC

This is perfect.
Thank you.

Loader.
Up arrow icon