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

Free Support Forum - aspose.com

How to read Video and Audio files inside a word document in vb.net with Aspose Word

Hi


How to read Video and Audio files inside a word document in vb.net with Aspose Word.


Thanks
Anil kasa

Hi Anil,


Thanks for your inqruiy. You can extract media files embedded as ole objects in word document as following. Hopefully it will help you to accomplish the task.

Dim doc As New Document(“DocWithVideos.docx”)<o:p></o:p>

Dim i As Integer = 0

' Get collection of shapes

Dim shapes As NodeCollection = doc.GetChildNodes(NodeType.Shape, True)

' Loop through all shapes

For Each shape As Aspose.Words.Drawing.Shape In shapes

If shape.OleFormat IsNot Nothing Then

shape.OleFormat.Save([String].Format("Data\out_{0}.{1}", System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1), shape.OleFormat.SuggestedExtension))

End If

Next


Please feel free to contact us for any further assistance.

Best Regards,

Hi Ahmad,


shape.OleFormat is nothing, even though I have Image and one video file in my document . Due to this I am unable to read Media elements in my word document.
Please help me in this, to read and save media files in a folder.

Thanks
Anil K.


Hi Anil,


Thanks for your feedback. We will appreciate it if you please share your sample Document here, we will look into it and will guide you accordingly.

Best Regards,

Hi Ahmad,


I attached my sample.docx file please check and replay as soon as possible.


Thanks
Anil K

Hi Anil,


Thanks for sharing the source document. We are looking into it and will update you shortly.

Best Regards,

Hi Ahmad,


Waiting for your replay, My team is in e-Learning platform so it is very necessary to read Audi and video file, so kindly replay as soon as possible. We are almost at last step to buy aspose.

Thanks
Anil Kasa

Hi Anil,


Thanks for your patience. I am afraid I am unable to find any media(audio/video) file in your shared document, both using Aspose.Words and MS Word. I will appreciate it if you please share some details how you find media files in this document using MS Word? So I will further investigate it and will guide you accordingly.

Furthermore, please note to extract images you need to use HasImage property as following and OleFormat is used for Media files(Audio/Video). Following code extracts two images from your sample document successfully.

Dim doc As New Document(“D:\Downloads\Sample (1).docx”)<o:p></o:p>

Dim i As Integer = 0

' Get collection of shapes

Dim shapes As NodeCollection = doc.GetChildNodes(NodeType.Shape, True)

' Loop through all shapes

For Each shape As Aspose.Words.Drawing.Shape In shapes

'For media files. For a shape that is not an OLE

' object or ActiveX control, returns null

If shape.OleFormat IsNot Nothing Then

shape.OleFormat.Save([String].Format("E:\Data\out_{0}.{1}", System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1), shape.OleFormat.SuggestedExtension))

End If

'For media images

If shape.HasImage Then

Dim imageFileName As String = String.Format("E:/Data/" + "Image.ExportImages.{0}_out{1}", System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1), FileFormatUtil.ImageTypeToExtension(shape.ImageData.ImageType))

shape.ImageData.Save(imageFileName)

End If

Next


We are sorry for the inconvenience.

Best Regards,

Hi Ahmad,


In my attached “sample.docx”, in last page i inserted a video file, That is like wise with word Option Insert —> Online Video Media. This is our embed video file. “ASPOSE” is reading this, as an Image file instead of a Embed Video. how to read embed video and audio files.


Note : The which you have posted above is working fine for normal audio and video files. But not able to read embed Video and audio files. Please check by downloading above “sample.docx” file.

Thanks
Anil kasa.

Hi Anil,


Thanks for your feedback. As stated above, we are unable to extract the media files from your shared document even using MS Word. We will appreciate it if you please share screen shots how you are extracting these embedded files as media files with MS Word. Because we find only images in the sample document.

We are sorry for the inconvenience.

Best Regards,