read word document from access database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Murphy

    #1

    read word document from access database

    How do you read/write a Word document embedded in an OLE Object field in an
    Access table with VB.NET?

    I have an Access application where users are creating and editing Word
    documents that are embedded in the database. I need to write a VB.NET
    application to routinely read the contents of these Word documents. I've
    written code that uses automation to open a Word document saved on disk and
    read the contents of the document but I don't know how to do the same if the
    document is inside a database.


  • Cor Ligthert

    #2
    Re: read word document from access database

    Tim,

    Mostly is that done using a blob field.
    In an oledb file there is a header in that blob.
    I have this sample for a picture in OleDB in a SQLserver, I assume that it
    is the same for the word document in access however this does not have to be
    true.

    Dim arrImage() As Byte = DirectCast(rdr. Item("Photo"), Byte())
    Dim ms1 As New System.IO.Memor yStream(arrImag e, 78, arrImage.Length - 78)

    I hope this helps
    (I am absolute not sure)

    Cor


    Comment

    • Paul Clement

      #3
      Re: read word document from access database

      On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert" <notmyfirstname @planet.nl> wrote:

      ¤ Tim,
      ¤
      ¤ Mostly is that done using a blob field.
      ¤ In an oledb file there is a header in that blob.
      ¤ I have this sample for a picture in OleDB in a SQLserver, I assume that it
      ¤ is the same for the word document in access however this does not have to be
      ¤ true.
      ¤
      ¤ Dim arrImage() As Byte = DirectCast(rdr. Item("Photo"), Byte())
      ¤ Dim ms1 As New System.IO.Memor yStream(arrImag e, 78, arrImage.Length - 78)
      ¤
      ¤ I hope this helps
      ¤ (I am absolute not sure)


      The header offset position depends upon the type of document. For Word files I believe it's 40.


      Paul ~~~ pclement@amerit ech.net
      Microsoft MVP (Visual Basic)

      Comment

      • Tim Murphy

        #4
        Re: read word document from access database

        78 nor 40 works. In fact I think its more than just a header offset. Doing a
        binary compare of the file I created in word then inserted into the database
        and out again they look very different. Some parts are similar but most
        noticeably the end section of the original looks to be at the top of the
        extracted document.

        Any more clues? I've done a google but I most be using the wrong keywords.
        Surely someone has been faced with this before me!

        Tim

        "Paul Clement" <UseAdddressAtE ndofMessage@sws pectrum.com> wrote in message
        news:tgq101hrnt ijfd5i5lfmiudtf h9rch2gf6@4ax.c om...[color=blue]
        > On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert"[/color]
        <notmyfirstname @planet.nl> wrote:[color=blue]
        >
        > ¤ Tim,
        > ¤
        > ¤ Mostly is that done using a blob field.
        > ¤ In an oledb file there is a header in that blob.
        > ¤ I have this sample for a picture in OleDB in a SQLserver, I assume that[/color]
        it[color=blue]
        > ¤ is the same for the word document in access however this does not have[/color]
        to be[color=blue]
        > ¤ true.
        > ¤
        > ¤ Dim arrImage() As Byte = DirectCast(rdr. Item("Photo"), Byte())
        > ¤ Dim ms1 As New System.IO.Memor yStream(arrImag e, 78, arrImage.Length -[/color]
        78)[color=blue]
        > ¤
        > ¤ I hope this helps
        > ¤ (I am absolute not sure)
        >
        >
        > The header offset position depends upon the type of document. For Word[/color]
        files I believe it's 40.[color=blue]
        >
        >
        > Paul ~~~ pclement@amerit ech.net
        > Microsoft MVP (Visual Basic)[/color]


        Comment

        • Tim Murphy

          #5
          Re: read word document from access database

          the magic number is 85!

          "Tim Murphy" <news@msolution s.com.au> wrote in message
          news:42012dee$0 $27854$61c65585 @un-2park-reader-01.sydney.pipen etworks.com.au. ..[color=blue]
          > 78 nor 40 works. In fact I think its more than just a header offset. Doing[/color]
          a[color=blue]
          > binary compare of the file I created in word then inserted into the[/color]
          database[color=blue]
          > and out again they look very different. Some parts are similar but most
          > noticeably the end section of the original looks to be at the top of the
          > extracted document.
          >
          > Any more clues? I've done a google but I most be using the wrong keywords.
          > Surely someone has been faced with this before me!
          >
          > Tim
          >
          > "Paul Clement" <UseAdddressAtE ndofMessage@sws pectrum.com> wrote in message
          > news:tgq101hrnt ijfd5i5lfmiudtf h9rch2gf6@4ax.c om...[color=green]
          > > On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert"[/color]
          > <notmyfirstname @planet.nl> wrote:[color=green]
          > >
          > > ¤ Tim,
          > > ¤
          > > ¤ Mostly is that done using a blob field.
          > > ¤ In an oledb file there is a header in that blob.
          > > ¤ I have this sample for a picture in OleDB in a SQLserver, I assume[/color][/color]
          that[color=blue]
          > it[color=green]
          > > ¤ is the same for the word document in access however this does not have[/color]
          > to be[color=green]
          > > ¤ true.
          > > ¤
          > > ¤ Dim arrImage() As Byte = DirectCast(rdr. Item("Photo"), Byte())
          > > ¤ Dim ms1 As New System.IO.Memor yStream(arrImag e, 78, arrImage.Length -[/color]
          > 78)[color=green]
          > > ¤
          > > ¤ I hope this helps
          > > ¤ (I am absolute not sure)
          > >
          > >
          > > The header offset position depends upon the type of document. For Word[/color]
          > files I believe it's 40.[color=green]
          > >
          > >
          > > Paul ~~~ pclement@amerit ech.net
          > > Microsoft MVP (Visual Basic)[/color]
          >
          >[/color]


          Comment

          • Cor Ligthert

            #6
            Re: read word document from access database

            Tim

            Thanks for letting us know.

            Cor


            Comment

            • Paul Clement

              #7
              Re: read word document from access database

              On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <news@msolution s.com.au> wrote:

              ¤ the magic number is 85!
              ¤

              The Classic VB code I have searches for the "ÐÏ" character string (without the quotes) in order to
              determine the offset. This might be a safer bet if you find that some Word documents have a
              different offset location.


              Paul ~~~ pclement@amerit ech.net
              Microsoft MVP (Visual Basic)

              Comment

              • Tim Murphy

                #8
                Re: read word document from access database

                Can you give us more details please. Source code would be even better.

                "Paul Clement" <UseAdddressAtE ndofMessage@sws pectrum.com> wrote in message
                news:6k94019nfv 48877snfp7e1ifd p9a1kdcbo@4ax.c om...[color=blue]
                > On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <news@msolution s.com.au>[/color]
                wrote:[color=blue]
                >
                > ¤ the magic number is 85!
                > ¤
                >
                > The Classic VB code I have searches for the "ÐÏ" character string (without[/color]
                the quotes) in order to[color=blue]
                > determine the offset. This might be a safer bet if you find that some Word[/color]
                documents have a[color=blue]
                > different offset location.
                >
                >
                > Paul ~~~ pclement@amerit ech.net
                > Microsoft MVP (Visual Basic)[/color]


                Comment

                • Paul Clement

                  #9
                  Re: read word document from access database

                  On Fri, 4 Feb 2005 08:33:33 +1100, "Tim Murphy" <news@msolution s.com.au> wrote:

                  ¤ Can you give us more details please. Source code would be even better.
                  ¤

                  I'll see if I can dig something up or port the existing Classic VB code.


                  Paul ~~~ pclement@amerit ech.net
                  Microsoft MVP (Visual Basic)

                  Comment

                  Working...