Detecting embedded Visio drawings in Word files

Hi there

I’m wondering how one would detect embedded Visio Files inside a Word document using Aspose.Words?

Is there a field type enumeration member which handles these file types?

Thanks

Eric

Hi Eric,
Thanks for your inquiry. I think you can use OleFormat.ProgId property to detect Visio objects:
https://reference.aspose.com/words/net/aspose.words.drawing/oleformat/progid/
Also, please attach your document here for testing.
Best regards,

Hi Andrey

I’ve attached the file in question - to be honest we actually dont really care what file type it is, once we can detect OLE embedded objects

Thanks

Eric

Hi
Thanks for your request. Your document contains 2 embedded OLE objects, which are Visio objects. You can use the following code to extract them from the document:

// Open document.
Document doc = new Document(@"Test001\in.doc");
// Get all shapes from the document.
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
int objectId = 0;
foreach(Shape shape in shapes)
{
    // Check if the shape is OLE object
    if (shape.OleFormat != null)
    {
        switch (shape.OleFormat.ProgId)
        {
            case "Visio.Drawing.11":
                shape.OleFormat.Save(string.Format(@"Test001\out_{0}.vsd", objectId));
                break;
        }
        objectId++;
    }
}

Hope this helps.
Best regards,

Hi Andrey,

Thanks for that - the code you gave me is working very nicely. One final is question - is it possible to retrieve the filename of embedded objects?

I tried querying the shape.OleFormat.SourceFullName property for the embedded objects in the file I sent you, but it just contains the empty string.

Thanks

Eric

Hi Eric,
Thanks for your request. You can extract embedded OLE object from the document using Aspose.Words. However you cannot get original name of an embedded document. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.
Best regards,

The issues you have found earlier (filed as 3257) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.