Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Word doc. and append to text file

Status
Not open for further replies.

rkckjk

IS-IT--Management
Apr 27, 2001
34
US
Currently. there is a Word doc. that the staff update throughout the day. I want to open this Word doc. and paste it's contents into a text file. This text file would be like a log or archival file which would grow everyday.
 
Quite simple if you know word vba

add the correct reference something like microsoft word 10.0 objects depending on what version you uses

then

Code:
        Dim wapp As New Word.Application
        Dim file_name As String

        file_name = ""

        wapp.ChangeFileOpenDirectory(System.IO.Path.GetFullPath(file_name))
        wapp.Documents.Open( _
            FileName:=System.IO.Path.GetFileName(file_name), _
            ConfirmConversions:=False, _
            ReadOnly:=False, _
            AddToRecentFiles:=False, _
            PasswordDocument:="", _
            PasswordTemplate:="", _
            Revert:=False, _
            WritePasswordDocument:="", _
            WritePasswordTemplate:="", _
            Format:=Word.WdOpenFormat.wdOpenFormatAuto)

        wapp.Selection.WholeStory()
        wapp.Selection.Copy
        TextBox1.Paste()

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top