Extract data from word to access?

C

CAD Fiend

Hello,

I am going to recieve about 250 word docs for a land survey project that
are all the same format. The document will have 4 main sections, and
then inside those, there will be details which will need to be captured
(or harvested) and then saved as delimited text (or whatever will work
best) for insertion into an access database.

The problem is that most (80%) of the word doc is not formatted into any
kind of tabular structure, at least from what I can tell. (As a side
note - is there a way to check using something like reveal codes, as was
in WP)? The only thing in common that each doc file has is that each
file has the same keywords preceding the desired data value.

MY QUESTION:

Is there a way to have a VBA routine go through, and identify (which
would be embedded in the VBA routine) keywords, and then based on that
keyword, trigger a "copy" to action? There is always a consistent
keyword preceding the desired data value.

For example, here is a typical sentance (with the desired data value in
{}, and the keyword in caps:

EXAMPLE 1) That certain tract of land CONTAINING {105.899}acres, more or
less...


EXAMPLE 2) or another example in tabular format, separated by tabs (but
shown here with commas and no separation);

1st line: *Surface,Mineral,Net
2nd line: Owner,*Interest,Interest,Mineral Acres
3rd line: John H. Smith,100%,50%,52.9495

* TO CLARIFY: The words Surface and Interest go together (like Surface
Interest), just one on top of each other. Same for the words Mineral and
Interest, as well as Net and Mineral Acres.

In sum, I just want to know what are the ways that you can go into an
existing word doc and extract the data that you need, that's all.

I really don't know where to begin asking this, but if there is a better
NG than this one, I'd apprieciate your direction on where I should post
this.

TIA.

Phil
 
D

Doug Robbins

This can probably done using some code that makes use of the Find function
with wildcards.

This is how it is used, but it is not exactly what you need for your
situation

' Macro to round all numbers in a document

' Macro created 19/7/00 by Doug Robbins

'

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,}.[0-9]{3,}", MatchWildcards: =
True, Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Text = Round(Selection.Range.Text, 2)
Loop
End With

To get more information on wildcards, see the article "Finding and replacing
characters using wildcards" at:

http://word.mvps.org/FAQs/General/UsingWildcards.htm


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

David Sisson

This is some code I put together recently. It finds text bewteen
parentheses, but I'm sure it could be used to find the acres.

Sub LookBetween()
'By David Sisson June 2005
'Return the info between paretheses
Dim rng, Rng2, Rng3 As Range
Dim MyRange As Range
Set rng = ActiveDocument.Range
Set Rng2 = rng.Duplicate
Set Rng3 = rng.Duplicate

Do
With Rng2.Find
.ClearFormatting
.Text = "("
.Forward = True
.Wrap = wdFindStop
.Execute
End With

'exit if not found
If Rng2.Find.Found Then
With Rng3.Find
.ClearFormatting
.Text = ")"
.Forward = True
.Wrap = wdFindStop
.Execute
End With

If Rng3.Find.Found Then
Begin = Rng2.Start
TheEnd = Rng3.Start + 1
rng.SetRange Rng2.Start + 1, Rng3.Start
MsgBox rng
End If
End If
Loop Until Not Rng2.Find.Found

End Sub

In your example two, will the data ALWAYS be formatted this way?

And what are you after? These look like headers.
Surface Interest, Mineral Interest, and Net Mineral Acres.

Or do you want the data after?
Owner: John Smith
Surface Interest: 100%
Mineral Interest: 50%
Net Mineral Interest: 52.9495

Will there be different headers?

As far as interfacing with Access, you could put all the data into a
Word table then do this.
http://www.word.mvps.org/faqs/tblsfldsfms/WordToAccess.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top