Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jada Mohammad   on Mar 14 In MS Office Category.

  
Question Answered By: Blandina Garcia   on Mar 14

Ohh... how disappointing!
I just KNEW I'd seen this topic in this group, so when my boss said
he needed to find a way of "extracting" specific data from 3,000 Word
files and enter it into an excel  file, I told him that it would be a
piece fo cake...

Now, I find that the thread isn't complete!

From what I've seen elsewhere, A BRUTE FORCE method would be to
programatically open each word  File, Save it as text, close the file.
Open the Txt file  as a text stream object, and loop through the data.
In my case, i'm looking for a specific string of characters.
If found, then I extract the entire line (which is tab delimited)
and insert it into the next line in the Excel sheet.

Now, another approach I'm pursuing is a bit less brutal.
I created a macro in which I select the entire document content
(selection.wholestory) then use split() to store it in an array.
Then, search through the array for the string in question.
(In this case, I'm looking for a 'tab' character followed by the
letters "AD")
Sub Macro1()
Dim TxtArray, i
Selection.WholeStory
' MsgBox Selection.Text
TxtArray = Split(Selection.Text, Chr(13))
' MsgBox UBound(TxtArray)
For i = 0 To UBound(TxtArray)
If (InStr(1, TxtArray(i), Chr(9) & "AD") > 0) Then
MsgBox TxtArray(i)
End If
Next i
End Sub
This seems to work... so now I have to see if I can put it all in an
EXCEL VBA module...

Any of you know of a "cleaner" way?

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Need to import information from a Word File Into Excel Or get search suggestion and latest updates.


Tagged: