Auto fill word form via access

torquay

Registered User.
Local time
Today, 16:02
Joined
Dec 27, 2005
Messages
85
I have been having problems trying to link access form field to a word form field.
Word is opening as it should but the field is empty. I am trying this with a blank word document with only the 1 linking field txtTitle and the name of the db field is frmTitle
I did notice that the word document is in a read only condition
I am using Office 2013. the code behind my button is as follows

Function fillwordform()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim Path As String

On Error Resume Next
Error.Clear
Path = "C:\Upload\test.docx"
Set appWord = GetObject(, "word.application")
If Error.Number <> 0 Then
Set appWord = New Word.Application
appWord.Visible = True
End If
Set docx = appWord.Documents.Open(Path, , True)
With docx

.FormFields("txtTitle").Result = Me!frmTitle

End With
appWord.Visible = True
appWord.Activate

Set doc = Nothing
Set appWord = Nothing
End Function

Private Sub FillWord_Click()
Call fillwordform
End Sub

Any guidance would be greatly recieved

Kim


I have got it somewhat working using legacy form controls on the word doc but I have some rich text in access that needs to come over to word and for some reason the legacy controls will not accommodate that
 
Last edited:

Users who are viewing this thread

Back
Top Bottom