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

Free Support Forum - aspose.com

Break OLE links in Word Documents


I’m using Java 1.5 with the Aspose.Words.jdk15.jar libaray.

I’d like to know how to iterate over all the OLE objects in a word document and break each of the links.




Thanks for your request. You should iterate over all the Shapes in the document. Shape.getOleFormat() returns null if the Shape is not an OLE object or ActiveX control. If Shape.getOleFormat() is not null, then you can work with an Ole Object. See the following link.

I hope that this information will help you.

Best regards.

Thanks for your reply.

I still have 2 questions:
1) How to get the Ole object when it is embedded in a table.The object I am dealing with is actually a linked worksheet inside a table in Word. Please see attached word document.
2) How to break the link to the Ole object so that the table will now appear as just a regular table in the Word document. I reviewed the API docs for the OleFormat class but am still unsure how to break the link. The OleFormat class does allow me to do other things like change the source file name of the Ole object.

// try breaking the links in the master document
NodeCollection tables = masterDocument.getChildNodes(NodeType.TABLE,true);
for(int i = 0; i < tables.getCount(); i++)
Table table = (Table)tables.get(i);
System.out.println(“Node type:” + node.getNodeType());

// get the reference to the underlying OLE object




Thanks for additional information. The link is the LINK field; you should remove this field from your document. Here is the C# code to achieve this.

Document doc = new Document(@"228_96505_jfair\test2.doc");

NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);

NodeCollection ends = doc.GetChildNodes(NodeType.FieldEnd, true);

foreach (FieldStart start in starts)


if (start.FieldType == FieldType.FieldLink)


Node node = start;

//remove node start and body

while (node.NextSibling.NodeType != NodeType.FieldSeparator)








// Remove field end

foreach (FieldEnd end in ends)


if(end.FieldType== FieldType.FieldLink)




I hope that it will help you.

Best regards.

Thanks Vitaly. This achieved what I needed. I am familiar with the Word object model provided by Microsoft but am still getting used to the API provided by Aspose. Rummaging through the java api docs to find the method you need is sometimes frustrating.