none
Convert Word document object to byte array in VBA code RRS feed

  • Question

  • Is it possible to convert a Word Document Object to a byte array in the VBA code? We need to convert the document in order to pass it to a web service for storage in a byte array within the document itself. The alternative is to save the document then convert it to a byte array and then finally delete the document.  This seems to be more processing than needed when the document is already in memory.  Is there a code example for doing this?
    Wednesday, July 8, 2015 4:47 PM

Answers

All replies

  • Hi,

    >>Is it possible to convert a Word Document Object to a byte array in the VBA code?

    I'm afraid Word Document Object couldn't support this using VBA. More properties and methods about Word Document , you may get information here,

    https://msdn.microsoft.com/en-us/library/office/ff822963.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 9, 2015 9:04 AM
    Moderator
  • Hi DC

    I don't understand why you'd store the byte array in the document, itself? Are you trying to take a "snapshot" of the current state of the document and have it travel with the document?

    What would be possible, assuming we're talking about Word 2007 or later, would be to the the document's Word Open XML, in the Open XML Packaging flat-file format. That would be a string, rather than a byte array but that shouldn't make any difference?

    Document.Content.WordOpenXML


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, July 9, 2015 1:29 PM
    Moderator
  • Hi DC

    A further thought:

    It should also be possible to copy the document to the Clipboard (Document.Content.Copy) then extract the information from the Clipboard and do something with it.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, July 9, 2015 1:30 PM
    Moderator