Solved

extract words from a document and store in a database field

Posted on 2013-11-06
3
612 Views
Last Modified: 2013-11-08
I would like to store the words from a word document, .doc or .docx, in a database field in order to speed up searches.

I have used the textstream command in access 10 vba to convert my text documents but wondered about the best way to extract the words from a Word document.

I thought about opening the .doc and saving it as a .txt and then using the textstream command to extract the data but wondered if there was a quicker, cleaner method of doing this?
0
Comment
Question by:Nemetona
3 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 300 total points
ID: 39627696
I would do the searching in Word, which has superior methods for finding text strings.  Make a Word macro to do the searching, and store the found words in your Access database.  You can use code like the following (from a Word VBA procedure) to work with an Access database.

Public Sub OpenAnotherDatabase()
'Created by Helen Feddema 14-Feb-2010
'Last modified by Helen Feddema 14-Feb-2010

   Dim appAccess As New Access.Application
   Dim strDBNameAndPath As String
   Dim dbs As DAO.Database
   Dim rst As DAO.Recordset
   Dim dbe As DAO.DBEngine
   
   'Change to your db name and path
   strDBNameAndPath = "G:\Documents\Access 2002-2003 Databases\General.mdb"
   appAccess.Visible = True
   appAccess.OpenCurrentDatabase filepath:=strDBNameAndPath, _
      exclusive:=False
      
   'Run a procedure
   'appAccess.Run "PrintOrdersReport"
   
   'Run a macro
   'appAccess.DoCmd.RunMacro "mcrPrintOrdersReport"
   
   'Run an action query
   'appAccess.DoCmd.OpenQuery "qryDeleteSomeOrders"
   
   'Run SQL code
   strSQL = "DELETE tblOrders.ShippedDate FROM tblOrders WHERE ShippedDate = #8/4/1994#;"
   Debug.Print "SQL string: " & strSQL
   'appAccess.DoCmd.RunSQL strSQL
   
   'Iterate through a recordset
   Set dbe = appAccess.DBEngine
   Set dbs = dbe.OpenDatabase(strDBNameAndPath)
    
   Set rst = dbs.OpenRecordset("tblCategories")
   Do Until rst.EOF
      Debug.Print rst![CategoryName]
      rst.MoveNext
   Loop
   rst.Close
    
   Set dbs = Nothing
   Set appAccess = Nothing
   
End Sub

Open in new window

0
 
LVL 15

Assisted Solution

by:DrTribos
DrTribos earned 200 total points
ID: 39628933
I'm not sure about textstream, never used it... you could perhaps load all the words from your document into a scripting dictionary and then move them straight into your database.  

I am assuming you will not be searching for phrases, just words.  You could exclude duplicates...  and for that mater also exclude words shorter than 4 characters etc...
0
 

Author Comment

by:Nemetona
ID: 39633937
Thanks for your responses, I obviously did not explain my problem to well and have since found a work around using saveas2
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Command button Click Event running twice on Double Click 9 40
Problem with vba code 4 45
Search feature 14 29
tab to another sub form 4 18
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

820 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