Please see the thread below for details, originally posted in the Access VBA coding forum but with no response.
thread705-951390
I created a Word form with multiple tables that I want to load into Access. The cells of the tables are all formfields. I have no problem reading the data from text box formfields, but the problem is with the drop-down formfields. My Word form allows the users to copy rows since it is not known exactly how many rows will be needed each time the form is used. That's where the problem is. When Word adds the row (my macro), the booksmarks are removed. If the bookmarks are removed, Access can’t “see” the data from the drop-down formfields. I have tested this fully and if I plug in bookmarks for all those drop-down formfields, the load works fine.
Thus, I know my problem is I need to find a way to “see” that data in the drop-down formfields. I was able to programmatically create the bookmarks in the word doc and I thought I was home free. But, for some reason, although I can confirm the bookmarks are there, the bookmark property with .result says it is not available in the collection. I am baffled. I do notice that when I programmatically add the bookmarks, when I look in the Word file, you can’t actually see the bookmark when you double-click in the field. I tried recording a macro in Word to see the actually code lines but the recorder won’t work for inserting a bookmark.
Here’s a sample of my code in Access where the problem lies.
If (lngRows - 2) = 1 Then doc.Bookmarks.Add NAME:="prob1", Range:=Selection.Range
If doc.Bookmarks.Exists("prob1") = True Then
MsgBox " true - line#: " & (lngRows - 2)
!problem = doc.FormFields("prob1").Result
End If
The first IF statement successfully adds the bookmark to the WORD doc. The second IF confirms the bookmark was added to the form field, but the line with !problem bombs with the message “Error 5941: Requested member of the collection does not exist”. I don’t understand that because in lines above this one where the field was not a drop-down (but still a formfield), I used this line to get the data in the drop-down (see next line):
![visit_summary1] = doc.FormFields("visitsumm1").Result
Any help would be appreciated. I have checked book after book, many sites and tek-tips and not much has been answered on Word automation regarding bookmarks on drop-down formfields.
Thanks,
Alexis
thread705-951390
I created a Word form with multiple tables that I want to load into Access. The cells of the tables are all formfields. I have no problem reading the data from text box formfields, but the problem is with the drop-down formfields. My Word form allows the users to copy rows since it is not known exactly how many rows will be needed each time the form is used. That's where the problem is. When Word adds the row (my macro), the booksmarks are removed. If the bookmarks are removed, Access can’t “see” the data from the drop-down formfields. I have tested this fully and if I plug in bookmarks for all those drop-down formfields, the load works fine.
Thus, I know my problem is I need to find a way to “see” that data in the drop-down formfields. I was able to programmatically create the bookmarks in the word doc and I thought I was home free. But, for some reason, although I can confirm the bookmarks are there, the bookmark property with .result says it is not available in the collection. I am baffled. I do notice that when I programmatically add the bookmarks, when I look in the Word file, you can’t actually see the bookmark when you double-click in the field. I tried recording a macro in Word to see the actually code lines but the recorder won’t work for inserting a bookmark.
Here’s a sample of my code in Access where the problem lies.
If (lngRows - 2) = 1 Then doc.Bookmarks.Add NAME:="prob1", Range:=Selection.Range
If doc.Bookmarks.Exists("prob1") = True Then
MsgBox " true - line#: " & (lngRows - 2)
!problem = doc.FormFields("prob1").Result
End If
The first IF statement successfully adds the bookmark to the WORD doc. The second IF confirms the bookmark was added to the form field, but the line with !problem bombs with the message “Error 5941: Requested member of the collection does not exist”. I don’t understand that because in lines above this one where the field was not a drop-down (but still a formfield), I used this line to get the data in the drop-down (see next line):
![visit_summary1] = doc.FormFields("visitsumm1").Result
Any help would be appreciated. I have checked book after book, many sites and tek-tips and not much has been answered on Word automation regarding bookmarks on drop-down formfields.
Thanks,
Alexis