Results 1 to 7 of 7

Thread: Export text from .DOC? (Resolved)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Arrow Export text from .DOC? (Resolved)

    Anyone know of a com object or something that can export unformatted text from a microsoft word documnt (.doc)?

    Thanks
    Last edited by nkad; Jul 17th, 2003 at 04:23 AM.

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Function DocText(ByVal DocName As String) As String
    2.  
    3.     ' Author:  WorkHorse
    4.     ' Purpose: Read Microsoft Word document text.
    5.     ' In:      Microsoft Word document file name.
    6.     ' Out:     Text of the Word document.
    7.     ' Notes:   Document text returned includes revision marking text.
    8.  
    9.     Dim lngHandle As Long   ' Handle for free file.
    10.    
    11.     On Error Resume Next
    12.    
    13.     ' Read file. Read as binary to read past End Of File characters.
    14.     lngHandle = FreeFile
    15.     Open DocName For Binary As #lngHandle
    16.         DocText = Input(LOF(1), #lngHandle)
    17.     Close #lngHandle
    18.  
    19.     ' Parse document text from file.
    20.     ' Document text starts at character 1537.
    21.     ' Document text ends at the first following null.
    22.     DocText = Mid$(DocText, 1537, (InStr(1537, DocText, Chr$(0))) - 1537)
    23.  
    24.     ' Convert carriage returns (paragraph marks)
    25.     ' to carriage return & line feed.
    26.     DocText = Replace(DocText, vbCr, vbCrLf)
    27.  
    28. End Function
    -= a peet post =-

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    Damn why didn't i think of that!

    Next time I will beat myself before I ask for help on a simple problem.

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by nkad
    Damn why didn't i think of that!

    Next time I will beat myself before I ask for help on a simple problem.
    good thing workhorse thought of it then
    -= a peet post =-

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    I would like to note that I just found out this code will only work with Microsoft Word 9.0 (office 2000) not Word 10.0 (Office XP)

    Need to look up the header offset for the version number and then seek to the correct byte offset.

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Great if you could post the solution once you find it
    -= a peet post =-

  7. #7
    Hyperactive Member
    Join Date
    May 2002
    Posts
    434
    Nkad

    Did you ever find the offset for the header on Word 10?

    Thanks

    David

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width