Open a Word doc. and append to a text file on a daily basis.

Posted on 2004-11-05
Last Modified: 2010-08-05
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 once a day using the Windows Task schedular.  This text file would be like a log or archival file which would grow everyday.
Question by:rkckjk
    LVL 28

    Accepted Solution

    YOu can read Word into string and then add this string to your text file

            Dim oWD As Object = CreateObject("word.application")
            Dim oDoc As Object = CreateObject("Word.Document")
            Dim spath As String
            spath = "c:\temp\wp.doc"  'change to your path

            oDoc = oWD.Documents.Open(spath)

            'Set and retrieve text
            Dim s As String
            Dim stringData As IDataObject
            Dim getString As New DataObject(DataFormats.StringFormat)
            stringData = Clipboard.GetDataObject()
            If stringData.GetDataPresent(DataFormats.Text) Then
                s = stringData.GetData(DataFormats.Text, True)
            End If

    LVL 28

    Expert Comment

    Another way to read the string (without clipboard)

    Dim oWD As Object = CreateObject("word.application")
            Dim oDoc As Object '= CreateObject("Word.Document")
            Dim spath As String
            spath = "c:\temp\wp.doc"

            oDoc = oWD.Documents.Add

            With oDoc.Content.Application.Selection
            End With

            ' Release the object variable
            oWD = Nothing

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now