I have an Access DB front end that is connected to an SQL Server 2000 backend. We use a MS Word form to collect info that will be uploaded into the Access form after clicking the Access form upload button that I have created.
I am able to open the doc and activate it but no reference to any field is recognized. I have added the MS Word Object reference and can send data to the Word form but cannot pull data from the Word form.
I have included some of the code for one field and most of the methods that I have tried. All of the code is in the Access form(s).
Question: How do I get the values of a MS Word form field to insert into an Access form? There is no working code below so all attempts are commented out.
Dim strPath As String
Dim oWord As Object
Dim oDoc As Object
strPath = Me.DOC_LOC
'Open MS-Word via OLE.
Set oWord = CreateObject("word.application")
'Open the form document.
Set oDoc = oWord.Documents.Open(strPath)
oWord.Documents(strPath).Activate
'oWord.Document(strPath).Activate
'oDoc.Document(strPath).Activate
'Form_frmREQSDATA.REQFRMBY.Value = oWord.Document.Bookmarks.FormFields("REQFORMBY").Result
'Form_frmREQSDATA.REQFRMBY.Value = CStr(oDoc.Fields("REQFORMBY").Result)
' Form_frmREQSDATA.REQFRMBY.Value = ActiveDocument.Bookmarks.Item("REQFRMBY").Range.Text
' Form_frmREQSDATA.REQFRMBY.Value = ActiveDocument.Bookmarks.Item("REQFRMBY").Range.Text
'' ActiveDocument.Bookmarks.Item("REQFRMBY").Select
'' Form_frmREQSDATA.REQFRMBY.Value = oWord.Selection.Text
oDoc.Close
Set oDoc = Nothing
Set oWord = Nothing
DoCmd.Close acForm, "frmUpload_Requirements", acSaveNo
Thank you in advance for any help or direction.
KO
I am able to open the doc and activate it but no reference to any field is recognized. I have added the MS Word Object reference and can send data to the Word form but cannot pull data from the Word form.
I have included some of the code for one field and most of the methods that I have tried. All of the code is in the Access form(s).
Question: How do I get the values of a MS Word form field to insert into an Access form? There is no working code below so all attempts are commented out.
Dim strPath As String
Dim oWord As Object
Dim oDoc As Object
strPath = Me.DOC_LOC
'Open MS-Word via OLE.
Set oWord = CreateObject("word.application")
'Open the form document.
Set oDoc = oWord.Documents.Open(strPath)
oWord.Documents(strPath).Activate
'oWord.Document(strPath).Activate
'oDoc.Document(strPath).Activate
'Form_frmREQSDATA.REQFRMBY.Value = oWord.Document.Bookmarks.FormFields("REQFORMBY").Result
'Form_frmREQSDATA.REQFRMBY.Value = CStr(oDoc.Fields("REQFORMBY").Result)
' Form_frmREQSDATA.REQFRMBY.Value = ActiveDocument.Bookmarks.Item("REQFRMBY").Range.Text
' Form_frmREQSDATA.REQFRMBY.Value = ActiveDocument.Bookmarks.Item("REQFRMBY").Range.Text
'' ActiveDocument.Bookmarks.Item("REQFRMBY").Select
'' Form_frmREQSDATA.REQFRMBY.Value = oWord.Selection.Text
oDoc.Close
Set oDoc = Nothing
Set oWord = Nothing
DoCmd.Close acForm, "frmUpload_Requirements", acSaveNo
Thank you in advance for any help or direction.
KO