Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing MS Word Fields (2000/SR-1)

    Is there a way to retrieve information from a field in a Word document from Access?

    What I have are contracts written in Word with fields gathering data, such as dates, names, terms, etc. I need to track contract terms, which are tied to specific dates. I would like to track the information in Access without having to manually re-enter the data (helping to prevent data entry errors.)

    I want to take the information from a Word field and place it into an Access field. I assume I use the MS Word Object Library but can find no way to access a specific field in the Word document.

    Any ideas?

    Thanks
    Will

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Accessing MS Word Fields (2000/SR-1)

    Hi Will,
    I think you would be better served to save the information you are tracking in Access, and create either reports or Word documents when you need them. If you want to do a one-time process of moving everything to Access, the simplest approach is to save the data in the Word document as a delimited text file and then import it into Access. You can also use OLE Automation to go the other way and put data into Access from Word (2000 and up) but it is much more complicated, and you loose the advantage of Access queries, forms and reports. Just my <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>!
    Wendell

  3. #3
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing MS Word Fields (2000/SR-1)

    Unfortunately, it can't work that way. The contracts are developed as templates by another organization and we are required to use them.

    Is there no way to access the Word field info using GetObject and the MS Word Object Library?

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Accessing MS Word Fields (2000/SR-1)

    Life tends to be that way, doesn't it. We've designed a couple of systems where Access builds the contracts - frankly it works far better than Word templates. But since you don't have that option:

    Here are a couple of references on the use of Automation between Access and Word:
    HOW TO: Use Automation to Find a Location in a Word Document in Access 2000
    ACC2000: How to Use Automation to Create a Word 2000 Merge Document
    ACC2000: How to Use Automation to Find Bookmarks in Word 2000 Documents

    You should also take a look at the Automation Help file:
    OFF2000: Microsoft Office 2000 Automation Help File Available

    As I indicated previously, it isn't a trivial task, and seems to work better when Access is the client and Word is the server, but it can be done.
    Wendell

  5. #5
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing MS Word Fields (2000/SR-1)

    Are the templates Word Forms, with FormFields?

    If so, then it's pretty easy to get the data out of the from fields.

    Make sure you have reference to the Word Object set

    then:

    you will need to something along these lines:

    <pre>Dim objWord as Word.Application
    Dim doc as Word.Document
    Dim ffl as Word.FormField

    set objWord = New Word.Application
    objWord.Visible = true

    set doc = objWord.Documents.Open("C:FullPathToWordForm.doc")

    for Each ffl in doc.FormFields
    Debug.Print ffl.Name & "=" & ffl.Result
    Next</pre>


    ffl.Name is the name of the FormField, which can be found in the Bookmark Field in the FormPield Properties Dialog in Word.

    ffl.Result is the value of the FormField, which is what gets typed into the Word Form.

    Does that make sense?
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  6. #6
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing MS Word Fields (2000/SR-1)

    That did it. Thank you very much. And now the real nightmare begins. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>

Posting Permissions

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