R
ryguy7272
I recently posted this in the Access Programming area, and after not
receiving any feedback, thought it may be more of a Word issue.
Basically, I am trying to push data from a Form to a Word.doc. I had this
working fine for a document with Bookmarks, but when I set it up for another
document,
with a different type of bookmark, a CheckBox, it didn’t work. For
instance, in Word > Forms > Check Box Form Field, I inserted several
CheckBoxes in my Word doc. Now, I am trying to push checks from an Access
form to my Word template. I’ve tried multiple things and can’t seem to get
it working. Is this possible? It seems to be quite easy to double-click a
CheckBox in Word and the ‘X’ goes in there easy enough; not sure if you can
control Word in the same manner, using Access.
The name of the Form is ‘Parient’, all code is below:
Below is my code:
Private Sub Command10_Click()
'Print customer slip for current customer.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc
..FormFields("Supine").Result = Me!Supine
..FormFields("Prone").Result = Me!Prone
..FormFields("ArmsUp").Result = Me!ArmsUp
..FormFields("ArmsSides").Result = Me!ArmsSides
..FormFields("ArmsAkimbo").Result = Me!ArmsAkimbo
..FormFields("ReversedTable").Result = Me!ReversedTable
..FormFields("Other").Result = Me!Other
..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description
End Sub
receiving any feedback, thought it may be more of a Word issue.
Basically, I am trying to push data from a Form to a Word.doc. I had this
working fine for a document with Bookmarks, but when I set it up for another
document,
with a different type of bookmark, a CheckBox, it didn’t work. For
instance, in Word > Forms > Check Box Form Field, I inserted several
CheckBoxes in my Word doc. Now, I am trying to push checks from an Access
form to my Word template. I’ve tried multiple things and can’t seem to get
it working. Is this possible? It seems to be quite easy to double-click a
CheckBox in Word and the ‘X’ goes in there easy enough; not sure if you can
control Word in the same manner, using Access.
The name of the Form is ‘Parient’, all code is below:
Below is my code:
Private Sub Command10_Click()
'Print customer slip for current customer.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc
..FormFields("Supine").Result = Me!Supine
..FormFields("Prone").Result = Me!Prone
..FormFields("ArmsUp").Result = Me!ArmsUp
..FormFields("ArmsSides").Result = Me!ArmsSides
..FormFields("ArmsAkimbo").Result = Me!ArmsAkimbo
..FormFields("ReversedTable").Result = Me!ReversedTable
..FormFields("Other").Result = Me!Other
..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description
End Sub