Convert Image File to Base64Binary RRS feed

  • Question

  • Does anybody know how to convert an image file to Base 64 using Excel VBA?  I am using Excel to save a chart as an image and then import it into OneNote.  OneNote apparently needs it in the form of a base64Binary to input as data.  This is actually a smaller part of a larger problem but I figured it would be better to break up my problem into smaller pieces.  However, anyone who is familiar with OneNote API and wants a challenge see

    The code that I currently have is below; I tried to convert it from but it is not working correctly.  The line sd.Save errors. 

        Dim sd As Bitmap
                sd = "C:\Users\MyUserName\SkyDrive\Charts\" & ChartName & ".jpg"
                Dim imgStream As MemoryStream
                imgStream = New MemoryStream
                sd.Save imgStream, Imaging.ImageFormat.jpg

                Dim byteArray As Byte
                byteArray = imgStream.ToArray()

                'Convert the byte[] to base64 string for use to upload.
                Dim final As String
                final = Convert.ToBase64String(byteArray)

    Thursday, July 24, 2014 6:51 PM


All replies