IconCaption of OleFormat is set automatically to "Packager" an cannot changed afterwards using .NET

Hello,

I am using .NET and insert there an OleObject with the progId “Package” using the DocumentBuilder method InsertOleObject. When I do this, the IconCaption of the OleFormat is always automatically set to “Packager”. Can I change this afterwards? Unfortunately, the IconCaption property has only a getter and no setter.

I have also seen the method InsertOleObjectAsIcon, but when I set the progId to “Package” afterwards, the information in the OlePackage property of the OleFormat does not seem to be filled in correctly because it is completely empty.

Thanks for your help!

@pschaumberger

It would be great if you please attach the following resources here for our reference.

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.

We will then provide you more information about your query along with code example.

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

I have attached the files and a short source code example in a text file as a ZIP to show you how I am currently doing this.

In general, the Word document should be included as a package object.

resources.zip (44.0 KB)

@pschaumberger

Please use the following code example to get the desired output. Hope this helps you.

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

builder.InsertOleObject(MyDir + "embeddedWordDocument.docx", "Word.Document.12", false, true, null);

document.Save(MyDir + "20.6.rtf");

Unfortunately this doesn’t help me a lot, because I need the Word document as a “package” and not directly as a word document. Because by embedding it as a “package” you have the possibility to get the file out of the Word document by copy and paste.

My actual problem was, that I can insert the document as a “package”, but then Aspose automatically sets the IconCaption from the OleFormat to “Packager” and because there is no setter, I cannot modify it afterwards.

See attached screenshots!

image.png (14.5 KB)
image.png (12.7 KB)

@pschaumberger

Please note that MS Word allows you copy or extract the content of embedded (package) Word document.

Please note that Aspose.Words mimics the behavior of MS Word. If you insert the OLE (Word document) using MS Word, it will be inserted with ‘Word.Document.12’ ProgID.

Could you please share the steps that you used to create expected_output.rtf? We will then provide you more information about your query.

When you add a Word document as an embedded object in a Word document using Microsoft Word itself, you generally have two options. 1. as a Microsoft Word document 2. as a package

The package gives you the ability to extract the embedded document to the file system. Unfortunately, if I embed a document as “Word.Document.12”, I do not have this option.

I have attached the steps how I generated the “expected_output.rft” manually using Microsoft Word.

step1.png (14.3 KB)
step2.png (8.9 KB)
step3.png (6.1 KB)
step4.png (3.9 KB)

@pschaumberger

With Aspose.Words, you can extract both type of embedded documents and save them to disk. Following code example show how to extract OLE objects. Hope this helps you. doc1.zip (31.8 KB)

Document doc = new Document(MyDir + "doc1.docx");
int i = 1;
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
    if (shape.OleFormat != null)
    {
        shape.OleFormat.Save(MyDir + "output" + i + ".docx");
        i++;
    }
}

Through Aspose Words it is possible programmatically, but when a user opens the Word document with the Microsoft Word application, you do not have the option there. So I need to include this as a “package” to ensure that when a user opens the Word documents we create by hand using Microsoft Office, the user will have the same behavior here.

Just as an additional hint. As I want to embed a word document as a package in the example, this can be any file type (.mov, .msg, etc) and these objects would surely be included as “Package” and here I could not modify the “IconCaption” either, which is then automatically set to “Packager” by Aspose.

@pschaumberger

Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-20702 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

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