Range from worksheet added as link problem

Hi,
We copy and paste range of cells from excel worksheet to word document. It can be pasted as “Link” to original excel worksheet. How to read information about this link, i.e. excel spreadsheet file name and referenced range of cells in that file?

At this moment we use following code to read word document in aspose.words:

static void Main(string[] args)
{
    var doc = new Document("main_document.docx");
    var shape = doc.GetChildNodes(NodeType.Shape, true).ToArray().Single() as Shape;
    Console.WriteLine(shape.ImageData.IsLink); //is always false
    Console.ReadKey();
}

Hi Marek,

Thanks for your inquiry. Please use the OleFormat.SourceItem to get or set a string that is used to identify the portion of the source file that is being linked. Use OleFormat.SourceFullName to get or set the path and name of the source file for the linked OLE object.

Please check the following code example and let us know if you have any more queries.

Document doc = new Aspose.Words.Document(MyDir + "main_document.docx");
// OLE embedded objects are available through OleFormat property of Shape object
// So first we should extract shapes from the document
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
// Loop through all shapes
foreach(Shape shape in shapes)
{
    // Check whether shape contains OLE object
    if (shape.OleFormat != null)
    {
        // We can determine type of an OLE object using ProgId property
        switch (shape.OleFormat.ProgId)
        {
            // Excel files
            case "Excel.Sheet.12":
                Console.WriteLine(Path.GetFileName(shape.OleFormat.SourceFullName));
                Console.WriteLine(shape.OleFormat.SourceItem);
                break;
        }
    }
}