R
ryguy7272
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.
The name of the Form is ‘Parient’, all code is below:
Option Compare Database
Sub PatientForm()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim objWord As Object
On Error Resume Next
err.Clear
Set appWord = GetObject(, "Word.Application")
Set objWord = CreateObject("Word.Application")
If err.Number <> 0 Then
objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True
End If
'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc
..CheckBox("Supine").Result = Forms!Patient!Supine
..CheckBox("Prone").Result = Forms!Patient!Prone
..CheckBox("ArmsUp").Result = Forms!Patient!ArmsUp
..CheckBox("ArmsSides").Result = Forms!Patient!ArmsSides
..CheckBox("ArmsAkimbo").Result = Forms!Patient!ArmsAkimbo
..FormFields("ReversedTable").Result = Forms!Patient!ReversedTable
..FormFields("Other").Result = Forms!Patient!Other
..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description
End Sub
I Used Forms, Checkbox, named the Bookmark, and clicked ‘Check Box Enabled’.
I tried a few types of objects such as ‘.CheckBox’ and ‘.FormFields’, but
not together…one then the other. Nothing has worked so far.
What am I doing wrong?
Thanks,
Ryan---
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.
The name of the Form is ‘Parient’, all code is below:
Option Compare Database
Sub PatientForm()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim objWord As Object
On Error Resume Next
err.Clear
Set appWord = GetObject(, "Word.Application")
Set objWord = CreateObject("Word.Application")
If err.Number <> 0 Then
objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True
End If
'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc
..CheckBox("Supine").Result = Forms!Patient!Supine
..CheckBox("Prone").Result = Forms!Patient!Prone
..CheckBox("ArmsUp").Result = Forms!Patient!ArmsUp
..CheckBox("ArmsSides").Result = Forms!Patient!ArmsSides
..CheckBox("ArmsAkimbo").Result = Forms!Patient!ArmsAkimbo
..FormFields("ReversedTable").Result = Forms!Patient!ReversedTable
..FormFields("Other").Result = Forms!Patient!Other
..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description
End Sub
I Used Forms, Checkbox, named the Bookmark, and clicked ‘Check Box Enabled’.
I tried a few types of objects such as ‘.CheckBox’ and ‘.FormFields’, but
not together…one then the other. Nothing has worked so far.
What am I doing wrong?
Thanks,
Ryan---