Identify embedded audio and video file details in a Word document

Viewed 25

I want to create some navigator functionality in a task pane for Word. I need to navigate through embedded images, audio and video files in the Word document. I implemented a logic and I am able to navigate through the images without a problem. But I am stuck in differentiating the embedded audio and video files. Below is my code.

    private void btnNext_Click(object sender, EventArgs e)
    {
        Word.Range objRange;
        Word.Range itemRange;
        int rangeStart = 0;

        objRange = wordApp.Selection.Range;
        rangeStart = objRange.Start;

        objRange.SetRange(rangeStart, this.wordDocument.Content.End);

        string selectedItem = this.comboBox1.Text;
        switch (selectedItem)
        {
            case "Graphics":
                foreach (Word.InlineShape shape in objRange.InlineShapes)
                {
                    if (shape.Type == Word.WdInlineShapeType.wdInlineShapePicture)
                    {                          
                        //Some code here for selecting the range of the image
                    }
                }
                break;

            case "Audio":
                foreach (Word.InlineShape shape in objRange.InlineShapes)
                {
                    if (shape.Type == Word.WdInlineShapeType.wdInlineShapeEmbeddedOLEObject)
                    {
                       //Here I got the problem on differentiating audio and video
                    }
                }
                break;
        }
    }

My problem is both audio and video have the Word.InlineShape.Type as Word.WdInlineShapeType.wdInlineShapeEmbeddedOLEObject. I tried lots of properties of the InlineShape object, but I couldn't get any supportive information at least the media file name displaying in the Word document. If I can get it, then I can extract the file extension and identify whether it is a video or an audio.

enter image description here

Please help me with identifying the audio and video items in a Word document separately.

Thank you in advance!

0 Answers
Related