We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set a file name and extension when insert ole object using MemoryStream?

how to set a file name and extension when insert ole object using MemoryStream?
var document = new Document();
var builder = new DocumentBuilder(document);
var shape = builder.InsertOleObject(“D:\1.zip”, false, true, null);

var document = new Document();
var builder = new DocumentBuilder(document);

        var bs = File.ReadAllBytes("D:\\1.zip");
        using (var stream=new MemoryStream(bs))
            var shape = builder.InsertOleObject(stream, "Package", true, null);

in the example2, when clicking on icon, it asks for the application to open that embedded file.
I dont wan’t to save data to file, because there are many data need to handle, is there any other method to set the file name and extension of inserted stream, so the microsoft word can recognize the file format?
i saw the return shape.OleFormat has two properties: SuggestedExtension and SuggestedFileName may can do this, but they are readonly.


Thanks for your inquiry. We are looking into your requirement and will update you soon.

Furthermore, please note SuggestedExtension and SuggestedFileName is read only properties used to get embedded Ole Objects information.

Document doc = new Document("Sample.docx");
int i = 0;
// Get collection of shapes
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
Console.Out.WriteLine("No. of Shapes:"+shapes.Count);
// Loop through all shapes
foreach (Aspose.Words.Drawing.Shape shape in shapes)
    if (shape.OleFormat != null)
        shape.OleFormat.Save(String.Format("E:\\Data\\out_{0}.{1}", i++, shape.OleFormat.SuggestedExtension));

Best Regards,

Is there any progress?


Thanks for your patience. After initial investigation, we have logged a ticket WORDSNET-15616 in our issue tracking system for your requirement. We will keep you updated about the issue resolution progress within this forum thread.

Best Regards,


The issues you have found earlier (filed as WORDSNET-15616) have been fixed in this Aspose.Words for .NET 17.11 update and this Aspose.Words for Java 17.11 update.

Please also check the following articles:


We would like to share with you that support of setting file name and extension was added in Aspose.Words 17.11. The public property OlePackage was added to the OleFormat class to set file name, extension and display name for OLE Package. Following code example shows how to use these properties.

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
byte[] bs = File.ReadAllBytes(@"c:\temp\input.zip");
using (Stream stream = new MemoryStream(bs))
    Shape shape = builder.InsertOleObject(stream, "Package", true, null);
    OlePackage olePackage = shape.OleFormat.OlePackage;
    olePackage.FileName = "FileName.zip";
    olePackage.DisplayName = "DisplayName.zip";