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
  1. Home
  2. General Programming
  3. Visual Basic
  4. VBA question: Putting ByteArray into an XML doc

VBA question: Putting ByteArray into an XML doc

Scheduled Pinned Locked Moved Visual Basic
data-structuresxmlhelpquestion
2 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.
  • P Offline
    P Offline
    pankajdaga
    wrote on last edited by
    #1

    Hi everone, I am using VBA for Visio and I want to store an image into an XML element. So, basically I read the image into a byte array like this: Dim FileNumber As Integer Dim imageBase64() as Byte FileNumber = FreeFile() Open "C:\hello.gif" For Binary As FileNumber ReDim imageBase64(LOF(FileNumber)) Get FileNumber, , imageBase64 Close FileNumber This reads the image data correctly into my byte array. But now wheever I attempt to put this into an XML element like: element.nodeTypedValue = imageBase64 This method does something to the image data and adds something else instead. What I want is to have the byte array as is. Any help would be greatly appreciated. Thanks! Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */

    D 1 Reply Last reply
    0
    • P pankajdaga

      Hi everone, I am using VBA for Visio and I want to store an image into an XML element. So, basically I read the image into a byte array like this: Dim FileNumber As Integer Dim imageBase64() as Byte FileNumber = FreeFile() Open "C:\hello.gif" For Binary As FileNumber ReDim imageBase64(LOF(FileNumber)) Get FileNumber, , imageBase64 Close FileNumber This reads the image data correctly into my byte array. But now wheever I attempt to put this into an XML element like: element.nodeTypedValue = imageBase64 This method does something to the image data and adds something else instead. What I want is to have the byte array as is. Any help would be greatly appreciated. Thanks! Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */

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

      That's because you haven't converted the image to an actual Base64 string. All you've done is read the binary data and attempted to write it to a text file. This, of course, writes all kinds of special characters to the file which are no legal in an XML document. You have to either find a VBA library to convert binary data into a Base64 string and back, or encapsulate the binary data in a !CDATA XML element. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      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