How to embed OLE object without extension in filename?

Embed OLE object without extension in filename

Method 1:

String filePath = "D:\\Program Files\\Atlassian\\Application Data\\JIRA\\data\\attachments\\RAO\\RAO-48\\13517";

builder.insertOleObject(filePath, "Word.Document.8", true, true, null);
doc.save(dataDir + "output.docx");

In this method, we are having file without extension. While embedding it into a word document, it shows that it has been embedded but on clicking the file icon in document nothing happens.

So we tried with Stream of above file as below

Method 2:

File fileTest = new File(filePath);
FileInputStream fisTest = new FileInputStream(fileTest);
builder.insertOleObject(fileInputStream, "Word.Document.8", true, null);

In this case the document is successfully embedded, but when clicking on icon, it asks for the application to open that embedded file
So, my query is regarding how do I insert OLE object so that it automatically opens with appropriate application on clicking on icon

Hi Sunil,

Thanks for your inquiry.

We have tested the scenario using latest version of Aspose.Words for Java 17.4 with test documents. We have not faced the shared issue. Please use Aspose.Words for Java 17.4. We have attached the OLE and output documents with this post for your kind reference.

Hi Tahir,
Thanks for the response. I tried with the files given by you, and it worked only for stream method properly. With file path method it did embed but unable to open.
I tried same for our file it failed while using Stream method. With file path method, I was unable to open the embedded doc.
I am attaching our file. Can you please check with it what is problem with our file?
Stream method details:

It works when we give prog id as “Pack” but it shows the pack icon and asks for application to open embedded doc
It doesnt work if we use “Word.Document.8”, it shows following exception

java.lang.IllegalStateException: This is not a structured storage file.
at asposewobfuscated.zzQL.(Unknown Source)
at asposewobfuscated.zzS2.(Unknown Source)
at com.aspose.words.zzZ7I.zzZ(Unknown Source)
at com.aspose.words.zzZ7I.zzZ(Unknown Source)
at com.aspose.words.DocumentBuilder.insertOleObject(Unknown Source)
at com.aspose.words.DocumentBuilder$insertOleObject$0.call(Unknown Source)
at AsposeEmbed.run(AsposeEmbed.groovy:113)

Hi Sunil,

Thanks for sharing the detail. We have tested the scenario and managed to reproduce the following issues at our side. For the sake of correction, we have logged these problems in our issue tracking system as follow:

WORDSJAVA-1549 : Embedded Word document does not open in output DOCX
WORDSJAVA-1550 : DocumentBuilder.InsertOleObject throws java.lang.IllegalStateException

You will be notified via this forum thread once these issues are resolved. We apologize for your inconvenience.

HI Tahir,
Yes it is working for DOC file created with word 2010. How can we embed this document with its name? Can a caption be given for embedded document?

Hi Sunil,

Thanks for your inquiry. Unfortunately, Aspose.Words does not provide API to set icon caption of OLE object. However, we have logged this feature request as WORDSNET-11833 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

Hi Tahir,
We are now using following method to embed files. We are not using any program id here.

builder.insertOleObject(tempAttachFile, false, true, null);

We are getting appropriate file icons for doc, xlsx, pdf.But we are getting default pacakager icon for.msg and.txt files

Is there any way that we could get appropriate icon.

Also can you please provide various program id supported by Aspose?

Hi Sunil,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Sunil,

Thanks for your patience.

tahir.manzoor:
WORDSJAVA-1550 : DocumentBuilder.InsertOleObject throws java.lang.IllegalStateException
WORDSJAVA-1549 : Embedded Word document does not open in output DOCX

Please upgrade to the latest version of Aspose.Words for Java 17.5 and use “Word.Document.12” as ProgId of OLE object to get the desired output.

MS Word doesn’t support linked OLE object to file without extension. If you face any issue, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this.

String filePath = MyDir + "oleDocument\\13518";

File fileTest = new File(filePath);
FileInputStream fisTest = new FileInputStream(fileTest);

DocumentBuilder builder = new DocumentBuilder();
builder.insertOleObject(fisTest, "Word.Document.12", true, null);
builder.getDocument().save(MyDir + "17.5 Java.docx");

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

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