473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help in writing VB program to read 1000 word documents and extract required info

Hi,

I need help in writing a VB6 program to read 1000 word documents and extract my required information into a .dbf file.

All word documents are having different information in a tabular form but the following fields are common in all of them:

Name, Address, City, Country, Telephone, Mobile, Fax, Email, Title, Remarks

I want to extract these fields with their information and append them into my master Address.dbf file

Thanks & Best Regards,

Farooqui
Sep 26 '07 #1
4 2611
jamesd0142
469 256MB
I'm new to this vb stuff myself, although i am sure it isnt possible to read data from word files.

I could be wrong however.
Sep 26 '07 #2
Hi,

I need help in writing a VB6 program to read 1000 word documents and extract my required information into a .dbf file.

All word documents are having different information in a tabular form but the following fields are common in all of them:

Name, Address, City, Country, Telephone, Mobile, Fax, Email, Title, Remarks

I want to extract these fields with their information and append them into my master Address.dbf file

Thanks & Best Regards,

Farooqui
i know you're writing in vb6 and this is vba, but it can probably help you along the way.

to handle word files, you will need to import the reference library "Microsoft Word 11.0 Object Library". you will also need to declare a word application.
Expand|Select|Wrap|Line Numbers
  1. Dim appWord As New Word.Application
to loop through the files, use a file system object to find the file names of e.g. all word documents in a user-specified folder. then open them using
Expand|Select|Wrap|Line Numbers
  1. appWord.visible = false
  2. appWord.Documents.Open(strFullFilePath)
if the table has the same structure in every document, and also the same orientation in relation to other tables (first or third table in each document, for example...), you can use the following code to access the data in the tables and place it in an array. i will use the fields Name and Address and assume they are located in the first and second columns of the first table in each document.

Expand|Select|Wrap|Line Numbers
  1. Dim index,intNameCol,intAddressCol,row As Integer
  2. Dim strName As String
  3.  
  4. ' Given that the info for each person is located in the first column of the first table in each document
  5. index = 1 ' table index within the document
  6. intNameColl = 1
  7. intAddressColl = 2
  8.  
  9. ' Get the table from word
  10. Dim tblItems As Word.Table
  11. Set tblItems = appWord.ActiveDocument.Tables(index)
  12.  
  13. ' Define a multidimensional array to keep the data. Do this outside of the loop to get word documents if you wish to get all the data before putting it in the database.
  14. Dim arrData() As String
  15.  
  16. ' Loop through the table to get all names
  17. For row = 1 To tblItems.Rows.Count
  18.     ReDim Preserve arrData(1 To 2, 1 To UBound(arrData, 2)) ' Adds another row to the array, no matter what size it is currently.
  19.  
  20.     arrData(1,row) = tblItems.Cell(row,intNameCol) ' gets Name
  21.     arrData(2,row) = tblItems.Cell(row,intAddressCol) ' gets Address
  22. Next
as to putting everything in the database, i am not familiar with the database format you're using, and can therefore not help you with that part.
Sep 26 '07 #3
i know you're writing in vb6 and this is vba, but it can probably help you along the way.

to handle word files, you will need to import the reference library "Microsoft Word 11.0 Object Library". you will also need to declare a word application.
Expand|Select|Wrap|Line Numbers
  1. Dim appWord As New Word.Application
to loop through the files, use a file system object to find the file names of e.g. all word documents in a user-specified folder. then open them using
Expand|Select|Wrap|Line Numbers
  1. appWord.visible = false
  2. appWord.Documents.Open(strFullFilePath)
if the table has the same structure in every document, and also the same orientation in relation to other tables (first or third table in each document, for example...), you can use the following code to access the data in the tables and place it in an array. i will use the fields Name and Address and assume they are located in the first and second columns of the first table in each document.

Expand|Select|Wrap|Line Numbers
  1. Dim index,intNameCol,intAddressCol,row As Integer
  2. Dim strName As String
  3.  
  4. ' Given that the info for each person is located in the first column of the first table in each document
  5. index = 1 ' table index within the document
  6. intNameColl = 1
  7. intAddressColl = 2
  8.  
  9. ' Get the table from word
  10. Dim tblItems As Word.Table
  11. Set tblItems = appWord.ActiveDocument.Tables(index)
  12.  
  13. ' Define a multidimensional array to keep the data. Do this outside of the loop to get word documents if you wish to get all the data before putting it in the database.
  14. Dim arrData() As String
  15.  
  16. ' Loop through the table to get all names
  17. For row = 1 To tblItems.Rows.Count
  18.     ReDim Preserve arrData(1 To 2, 1 To UBound(arrData, 2)) ' Adds another row to the array, no matter what size it is currently.
  19.  
  20.     arrData(1,row) = tblItems.Cell(row,intNameCol) ' gets Name
  21.     arrData(2,row) = tblItems.Cell(row,intAddressCol) ' gets Address
  22. Next
as to putting everything in the database, i am not familiar with the database format you're using, and can therefore not help you with that part.

Thankyou very much for your help. Its Ok, I will switch from VB6 to VBA that doesn't matter. I would really appreciate if you could guide me for the second part as well. My database is in DBF and its format is:
Name String 50
Address String 75
Email String 50
......

One more query I would like to know that in some of my word documents, the sequence is litthe different means I can't use array to get the exact rows location, means Name is sometimes at row 4 and Address is at row 1. How should I handle this?

Thanks once again
& Best Regards

Farooqui.
Oct 4 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

How do u come to know that name is in 4th or 5th row..? does it have any Prefix Chars...? (say Mr. Ms....? Name..) if yes, then u can check for that Specific Word and take accordingly..

REgards
Veena
Oct 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
1
by: Derek | last post by:
I have a simple app that logs details of my customers and the work done for them. It uses a few tables in Access and allows me to keep a basic record of things for my accountant. How can I...
2
by: leo2100 | last post by:
Hi, I need help with this program. The program is supposed to take a text file and identify the words in it, then it should print them and count how many times a word is repeated. At first main...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: raypjr | last post by:
Hi everyone. I need a little help with some parts of a word guessing game I'm working on. I have some parts done but unsure about others and could use a little advice. Any help is very much...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
6
by: cj2 | last post by:
I need to create a cover letter in VB. It will have a customers account number at the top and be addressed to them by name for example (Dear Mr. Smith). After this it will be the same text for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.