Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing from Word 1

Status
Not open for further replies.

Evil6

Technical User
May 6, 2004
59
PT
Hello,

I have a file in word that is like this:

Name 1
Address 1
Phone 1
Postal Code 1
Comments 1

Name 2
Address 2
Phone 2
Postal Code 2
Comments 2

And so on, intil 300 and something. How can I import that into records to an Access table strtured more or less with the above mentioned fields?

Thank you.
 
Hallo,

You could write an MS Word macro to convert NewLine followed by non-newline to a comma, and NewLine followed by Newline to a single Newline. This would convert the file to CSV format which you canimport into MS Access.
Or something like that, if your file isn't a simple as you say,


- Frink
 
you can directly read the ms word file, if you set a reference to word

e.g.
Code:
Public Function ImportWordAddresses()
  Dim doc           As Word.Document
  Dim varAddresses  As Variant
  Dim i             As Long
  
  Const WORD_FILE As String = "c:\path\to\your\document.doc"
  
  Set doc = Word.Documents.Add(WORD_FILE)
  
  varAddresses = Split(doc.Range, Chr(11))
  
  For i = 0 To UBound(varAddresses) - 1
    Debug.Print varAddresses(i)
  Next i
  
  doc.Close
  Set doc = Nothing
  
End Function

Cheers,
Dan
 
There are two parts to this task: importing the data and normalizing the data.

There are many ways to import the data. I would select everything and choose "copy". Then I would open Excel and choose "paste". Now the data is in Excel. Open Access and choose "get external data/import" from the file menu.
A wizard starts. Work through the wizard and import the data. If there are more 256 fields, then you will need to perform the import repeatedly. You will need to include the primary key in each import.

Normalizing the data will be a more complex task. We can help you with that once everything is in Access.
 
Thank you for your answers.

I'll try what you suggest and I'll get back to you.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top