Exporting Images From Word
-
Ok, I know what you are thinking. :doh: Why was this posted on the web forum? Well, let me explain. I Have a DHTML text editor that I currently import Microsoft Word documents into via IE. The only problem is only text comes across currently. I came across info on MSDN that said images can be saved out of Word 2003 as bmp files. So far I can open the document, get a handle on each image, and copy them to the clipboard, but for some odd reason, probably my fault :rolleyes:, I can't seem to save them to the hard drive. I've included the code below, perhaps you can assist, especially if you know MS VB.NET and VBScript better than I, which wouldn't be difficult to do. ;-) Basically I get the image copied to the clipboard fine but then I don't seem to be saving anything out. Nothing fails, it just doesn't save. Any help would be greatly appreciated. ;) Sub ImportWordDoc() On Error Resume Next Set wApp = CreateObject("Word.Application") wApp.Activate wApp.WindowState=0 call wApp.Resize(400, 400) Set wDoc = wApp.Documents.Open(document.all.FileToOpen.value) wApp.Visible = true For index = 1 To wDoc.InlineShapes.Count inlineShape = "" Set inlineShape = wApp.ActiveDocument.InlineShapes(index) inlineShape.Select() wApp.Selection.CopyAsPicture() data = "" Set data = Clipboard.GetDataObject() If data.GetDataPresent( GetType( System.Drawing.Bitmap )) Then bmp = "" bmp = CType(data.GetData(GetType(System.Drawing.Image)), Bitmap) bmp.Save( "C:\mybitmap" + cstr(index) + ".bmp" ) End If Next Call wDoc.Close(True) call wApp.Quit(True) End Sub