Hi There,
I need a big help from you guys.
I have been tried to get this Word Form (2013) into Access (2013) for two days. Like to let you know that I don't know any thing about vba codes at all. Thanks.
Here is the vba code that I copy from MS website:
Option Compare Database
Sub GetWordData()
Dim appWord As Word.Application
Dim docx As Word.Document
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strDocxName As String
Dim blnQuitWord As Boolean
On Error GoTo ErrorHandling
strDocName = "C:\Contracts\" & _
InputBox("Enter the name of the Word contract " & _
"you want to import:", "Import Contract")
Set appWord = GetObject(, "Word.Application")
Set docx = appWord.Documents.Open(strDocxName)
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\CDAC\" & _
"HealthcareContracts-new.accdb"
rst.Open "tblContracts", cnn, _
adOpenKeyset, adLockOptimistic
With rst
.AddNew
!FirstName = docx.FormFields("fldFirstName").Result
!LastName = docx.FormFields("fldLastName").Result
!Company = docx.FormFields("fldCompany").Result
!Address = docx.FormFields("fldAddress").Result
!City = docx.FormFields("fldCity").Result
!State = docx.FormFields("fldState").Result
!ZIP = docx.FormFields("fldZIP1").Result
!Phone = docx.FormFields("fldPhone").Result
!SocialSecurity = docx.FormFields("fldSocialSecurity").Result
!Gender = docx.FormFields("fldGender").Result
!BirthDate = docx.FormFields("fldBirthDate").Result
!AdditionalCoverage = _
docx.FormFields("fldAdditional").Result
.Update
.Close
End With
docx.Close
If blnQuitWord Then appWord.Quit
cnn.Close
MsgBox "Contract Imported!"
Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set docx = 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