please help me out!!! import word into access 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi. I'm new programming in access and I need to import word doc with drop
down menues into my access DB.

does anyone know how to do it?
thanks for your help in advance.
 
actually I didn't do the word document so I'm not sure how it was done. but I
have "gray areas" that if you click there, you have a drop down menu where
you can choose from different options....
 
I am not sure what kind of object you have there but why not just try and
copy then paste in Excel to see how it would look in Access. Then import or
copy and paste append in Access.
 
the thing is that I don't want to copy it to excel. here is what I have

1) a database with an order table (id order, supplies, need), need table (id
and description), employee table (id and name)

the word document that I have is where people place their orders as I said
before they can choose for eg their needs with a drop down menu (i.e. need:
now, tomorrow, next week)

I need to import those fields in my database, but not only the need, as I
have the need table i would need something to convert that "now" or
"tomorrow" into my index (i.e. now=1)

thank you a lot in advance for your help
 
Why not use field "WHEN" where "now" = 0, "tomorrow" = 1, and "next week" = 7.
After import use an update query to translate from words to number.
 
actually what I need is pretty similar of what another person wrote...
"importing word into Access 2000." by "lula" but noone answered her either.

do you know what she needs to do??? I have to do basically the same.

thank you
 
I believe those are known as 'document fields' in Word. There isn't anything
built-in to Access to import them. It could probably be done by writing code
to automate Word, or possibly, in recent versions of Office, it might be
possible to use XML. I expect it will probably prove to be a non-trivial
development project either way.

You may find something useful at the following URL ...

http://msdn.microsoft.com/office/understanding/word/
 
ok, thank you anyways.... that link that you sent me is too further away from
my knowledge...haha, but ok, I think that it's better just to import the
records manually, right??

thank you for your help
 
See my response to Lula's second post.

actually what I need is pretty similar of what another person wrote...
"importing word into Access 2000." by "lula" but noone answered her either.

do you know what she needs to do??? I have to do basically the same.

thank you
 
See John's response. From what John posted, it looks as though it may not be
quite as complex as I thought it would be, but it is going to require some
programming.
 
John:

I went to this link and copied the code that Sean wrote...I modified the
location of the word docs and the db and field names...When I invoke the
macro though it comes back with an error of "user-define type not
defined"...It gives me this at this row in the code:

im cnn As New ADOdb.Connection

I am not a programer and am trying to do this through trial and error...Can
you give me a hint...I am using Access 2003 and a word doc using MS Word
11.0...

Thanks!
Snowiii
 
snowiii said:
John:

I went to this link and copied the code that Sean wrote...I modified the
location of the word docs and the db and field names...When I invoke the
macro though it comes back with an error of "user-define type not
defined"...It gives me this at this row in the code:

im cnn As New ADOdb.Connection

I am not a programer and am trying to do this through trial and
error...Can
you give me a hint...I am using Access 2003 and a word doc using MS Word
11.0...

Thanks!
Snowiii
 
apologies for the blank reply.

Make sure you have a reference set to the ADODB library.
When in the code window, choose Tools | References
In the dialog that opens, scroll down the list of references to Microsoft
ActiveX Data Objects
I'm not sure which number is for Access 2000,
just choose the highest from 2.1 to 2.6
or whatever are listed in your dialog for
Microsoft ActiveX Data Objects 2.1 Library.
Check the check box to on for this reference.
Close the dialog.
Now try your code.

Jeanette Cunningham
 
Thanks Jeanette, that did the trick!

snowiii

Jeanette Cunningham said:
apologies for the blank reply.

Make sure you have a reference set to the ADODB library.
When in the code window, choose Tools | References
In the dialog that opens, scroll down the list of references to Microsoft
ActiveX Data Objects
I'm not sure which number is for Access 2000,
just choose the highest from 2.1 to 2.6
or whatever are listed in your dialog for
Microsoft ActiveX Data Objects 2.1 Library.
Check the check box to on for this reference.
Close the dialog.
Now try your code.

Jeanette Cunningham
 
Any ideas on writing the code from the link to import mutiple word documents
at once rather than one at a time? Typing in the name of 200+ files one at a
time daily isn't any better than printing them down...

snowiii
 
it's probably possible, some more info needed.
Are the files all in the same folder?

Jeanette Cunningham
 
Yes, they will in the same folder...

snowiii

Jeanette Cunningham said:
it's probably possible, some more info needed.
Are the files all in the same folder?

Jeanette Cunningham
 
Here is some code that will loop through a folder and then process the word
doc with your code.
I haven't had time to set up some docs and test it, you may need to debug it
..
You need to add the path of the docs you want to process - this is hard
coded where you see strPath = "C:\....."

The process imports the first word doc, renames the doc with xx in front of
the doc name and then does the next doc.
You will end up with every word doc renamed with xx in front of the file
name.
This code assumes that only word docs are stored in the folder.


Sub GetWordData()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim blnQuitWord As Boolean
Dim strPath As String
Dim strSourceFolder As String
Dim strFileName As String

On Error GoTo ErrorHandling

'hard code the path and folder where the word forms are stored
strPath = "C:\....."

strSourceFolder = strPath & "\"

strFileName = Dir(strSourceFolder)

Set appWord = GetObject(, "Word.Application")

Do While Left$(strFileName, 2) <> "xx"
strFileName = Dir(strSourceFolder)
If Left$(strFileName, 2) = "xx" Then
'don't process
Else
'Debug.Print strFileName


Set doc = appWord.Documents.Open(strFileName)

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\My Documents\" & _
"Healthcare Contracts.mdb;"
rst.Open "tblContracts", cnn, _
adOpenKeyset, adLockOptimistic

With rst
.AddNew
!FirstName = doc.FormFields("fldFirstName").Result
!LastName = doc.FormFields("fldLastName").Result
!Company = doc.FormFields("fldCompany").Result
!Address = doc.FormFields("fldAddress").Result
!City = doc.FormFields("fldCity").Result
!State = doc.FormFields("fldState").Result
!ZIP = doc.FormFields("fldZIP1").Result & _
"-" & doc.FormFields("fldZIP2").Result
!Phone = doc.FormFields("fldPhone").Result
!SocialSecurity = doc.FormFields("fldSocialSecurity").Result
!Gender = doc.FormFields("fldGender").Result
!BirthDate = doc.FormFields("fldBirthDate").Result
!AdditionalCoverage = _
doc.FormFields("fldAdditional").Result
.Update
.Close
End With
doc.Close

Name strSourceFolder & strFileName As strSourceFolder & "xx" &
strFileName
End If
Loop


If blnQuitWord Then appWord.Quit
cnn.Close
MsgBox "Contract Imported!"

Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set doc = Nothing
Set appWord = Nothing
Exit Sub
ErrorHandling:
Select Case Err
Case -2147022986, 429
Set appWord = CreateObject("Word.Application")
blnQuitWord = True
Resume Next
Case 5121, 5174
MsgBox "You must select a valid Word document. " _
& "No data imported.", vbOKOnly, _
"Document Not Found"
Case 5941
MsgBox "The document you selected does not " _
& "contain the required form fields. " _
& "No data imported.", vbOKOnly, _
"Fields Not Found"
Case Else
MsgBox Err & ": " & Err.Description
End Select
GoTo Cleanup
End Sub


Jeanette Cunningham
 
Back
Top