Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Exporting Images From Word

Exporting Images From Word

Scheduled Pinned Locked Moved Visual Basic
helpgraphicscsharpdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ironclads
    wrote on last edited by
    #1

    Ok, I know what you are thinking. Why was this posted on the VB.Net 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 , 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 Any help or suggestions would be greatly appreciated. Tim

    D 1 Reply Last reply
    0
    • I ironclads

      Ok, I know what you are thinking. Why was this posted on the VB.Net 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 , 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 Any help or suggestions would be greatly appreciated. Tim

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      ironclads wrote: 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 Does your code even get to the "bmp = CType(data.GetData(..." line? A possibility would be that you're not actually seeing a Bitmap on the clipboard. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      I 1 Reply Last reply
      0
      • D Dave Kreskowiak

        ironclads wrote: 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 Does your code even get to the "bmp = CType(data.GetData(..." line? A possibility would be that you're not actually seeing a Bitmap on the clipboard. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        I Offline
        I Offline
        ironclads
        wrote on last edited by
        #3

        Yes, I've done alert prompts after the bmp save and they come up for each image, so I know its getting into the if statement. Any other help or suggestions for me? Thanks. <<<<TIM>>>>

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups