Free Support Forum -

Update embedded .mp3 file in Word .docx and convert to PDF

Hi Aspose folk,

Is it possible to update an embedded .mp3 file in a Word .docx (which presumably is an OLE object??) and replace the original file with a different .mp3 file.

Secondly, can an embedded .mp3 file be a cell of a table row and will it be duplicated if you duplicate that table row (and can you then update each of those files with different .mp3 files)?

If so, can you share code samples to do these tasks?

Also, what will happen to that embedded .mp3 file when the Word doc is converted to PDF? Does it end up being embedded in the resulting PDF?

Many thanks,


Thanks for your request. Inserting new OLE objects into Word documents and updating existing OLE objects is not supported. Inserting an OLE object usually requires the host application and probably cannot be done by Aspose.Words.

What is supported is preserving OLE objects in documents. That is if you open an MS Word document and then save it (possibly in another MS Word format) then OLE objects are preserved. You can also access objects programmatically, extract their data and preview image. However, creating and updating new OLE objects is not supported.

Regarding converting to PDF, only visual representation of an OLE object will be rendered to PDF.

Best regards,

Even treating the embedded file simply as a blob / sequence of bytes? I don’t need to parse the object, just replace one object with another of the same type?

I note there is an enum value FieldEmbed in FieldType as part of the Aspose.Words.Fields namespace. We can control the source document (it’s a template we are updating). Is it possible to put the embedded file in a field and update the field?

Alternatively, is it possible to use the Aspose PDF or PDF Kit classes to embed a sound file directly generated PDF?

Kind regards

Another option I’d consider - is it possible to put a file:// hyperlink into the document (with an icon?) but make that relative to the Word document. So if we ship the two together, someone can still click on the icon and play the audio - which is really what we are trying to achieve.

In that scenario, would the relative hyperlink translate appropriately when converted to PDF?

Thanks in advance,


Thank you for additional information. Unfortunately there is no way to achieve what you need using Aspose.Words.

Regarding Aspose.Pdf and Aspose.Pdf.Kit, please ask your questions in the appropriate forums. My colleguaes will answer you shortly.

Best regards,

Hi Damian,

Thanks for your inquiry.

I did some quick tests on my side and it looks as if the second option you presented is possible. Using the code below will produce an icon that when clicked will attempt to open “Song.mp3” which is found along side the PDF.

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-ansi-language:EN-NZ;
mso-fareast-language:ZH-CN;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:EN-NZ;
mso-fareast-language:ZH-CN;mso-no-proof:yes”> doc = new
Document(Document.doc"<span style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:EN-NZ;
<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-ansi-language:EN-NZ;
mso-fareast-language:ZH-CN;mso-no-proof:yes”>DocumentBuilder<span style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:EN-NZ;
mso-fareast-language:ZH-CN;mso-no-proof:yes”> builder = new DocumentBuilder(doc);

Shape audioIcon = builder.InsertImage("icon.png");

audioIcon.HRef = "Song.mp3";

doc.Save("Document Out.pdf");

I tested on my side using Adobe Acrobat Professorial. Please let us know how you go.


Thanks Adam. We will test it out and let you know how it works for us.