OLE objects are blocked after inserting them into DOCX using Java

Hello Aspose Team,

I am trying to add Ole object in Word output using Aspose Word (java) library, using version of insertOleObject which accepts input stream. See below code.

InputStream spreadsheetStream = new FileInputStream(“C:\TaskTracker\7.0.1\ole\” + “sheet1.xlsx”);

docBuilder.writeln(“Spreadsheet Ole object:”);
docBuilder.insertOleObject(spreadsheetStream, “MyOleObject.xlsx”, false, null);

In the output word file, on clicking on the OLE icon i get the error “Office has blocked access to following embedded object to keep you safe” “unknown”. see screen shot attached. blocked_access.PNG (41.2 KB)

When i right click on the icon and try to save the ole on desktop, it saves as “unknown” file. If rename and provide correct extension “xlsx” then that temporary desktop file opens.

I tried the other version of insertOleOjbect function, which takes filepath instead of stream and it was working fine. e.g

File file = new File(“C:\TaskTracker\7.0.1\ole\” + “sheet1.xlsx”);
docBuilder.insertOleObject(file.getAbsolutePath(), false, false, null);

Please help me on why i am getting “blocked access…” error on using InputStream of file instead of file name.

Zeeshan Khan
IBM Engineering Lifecycle Optimization - Publishing.


To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input documents.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hello Tahir,

Thanks for your reply.

I have attached the POC project as zip AsposeWords2.zip (98.7 KB)

I have removed the aspose-words-19.3.0-jdk16.jar and aspose license file.

The java code is in file AsposeTests_ole3.java

The generated output is actual_output.doc inside the zip.

The expected output is that that inserted ole should get opened.

Please let me know if require more information.

Zeeshan Khan


We have not found the sheet1.xlsx, ppt1.pptx, and doc11.docx files in the shared ZIP file. Please ZIP and attach them for testing.

We suggest you please try the latest version of Aspose.Words for Java 20.1 and let us know how it goes on your side. Hope this helps you.

Hello Tahir,

I tried with Aspose word 20.1 also but with same issue.

The file are just dummy files with random test data for POC you can use any but still attaching them.dummyfiles.zip (80.5 KB)

Zeeshan Khan
IBM Engineering Lifecycle Optimization - Publishing


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19961. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

When is the issue WORDSNET-19961 targeted i.e when can we expect the fix?

Also is there better way i can track this issue?

Zeeshan Khan
IBM Engineering Lifecycle Optimization - Publishing


Please pass the correct ProgID in DocumentBuilder.insertOleObject method as shown below to get the desired output. We have closed this issue as ‘Not a bug’.

Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);

// Let's take a spreadsheet from our system and insert it into the document
InputStream spreadsheetStream = new FileInputStream(MyDir + "sheet1.xlsx");

docBuilder.writeln("Spreadsheet Ole object:");
docBuilder.insertOleObject(spreadsheetStream, "Excel.Sheet.12", false, null);

InputStream powerpointStream = new FileInputStream(MyDir + "ppt1.pptx");
docBuilder.writeln("Powerpoint Ole object:");
docBuilder.insertOleObject(powerpointStream, "PowerPoint.Show.12", true, null);

InputStream wordStream = new FileInputStream(MyDir  + "doc11.docx");
docBuilder.writeln("Word Ole object:");
docBuilder.insertOleObject(wordStream, "Word.Document.12", false, null);

doc.save(MyDir + "output.doc");