?
Solved

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

Posted on 2004-11-05
2
Medium Priority
?
202 Views
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.
0
Comment
Question by:Richard Kreidl
  • 2
2 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 1000 total points
ID: 12513146
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)
        oWD.Documents(1).Select()
        oWD.Selection.Copy()

        '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

        MsgBox(s)
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12513343
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
        oWD.Documents.Open(spath)
        oWD.Documents(1).Select()


        With oDoc.Content.Application.Selection
            MsgBox(.Text)
        End With

        oWD.Application.Quit()
        ' Release the object variable
        oWD = Nothing
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 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