I will look at your posts in detail in a bit, I just do not have time right now. A glance tells me that "normal" problems at at issue. File locations and ordering of inserted bookmarks...
Here is a sample chunk of code. I will explain after.
Code:
Sub GetResults()
Dim oDoc As Document
Dim oDocAnswers As Document
Dim oDocResult As Document
Dim docFF As FormFields
Dim oFF As FormField
Code:
Set oDocAnswers = Documents("Answers.doc")
Set oDoc = Documents("Survey.doc")
Set oDocResult = Documents(1)
Set docFF = oDoc.FormFields
' if Q1 has Yes and not No
If docFF("Q1_Yes").Result = True And _
docFF("Q1_No").Result = False Then
oDocResult.Range.InsertAfter _
oDocAnswers.Bookmarks("Q1_Yes").Range.Text
End If
' if Q2 has Yes and not No
If docFF("Q2_Yes").Result = True And _
docFF("Q2_No").Result = False Then
oDocResult.Range.InsertAfter _
oDocAnswers.Bookmarks("Q2_Yes").Range.Text
End If
' if Q3 has Yes and not No
If docFF("Q3_Yes").Result = True And _
docFF("Q3_No").Result = False Then
oDocResult.Range.InsertAfter _
oDocAnswers.Bookmarks("Q3_Yes").Range.Text
End If
End Sub
The code is in a template (BuildResults.dot). The template creates a new blank document. The document Answers.doc has the bookmark chunks that will be used - it is OPEN. The document Survey.doc is a sample survey return document - it is OPEN.
The code in the template makes a document object of Answers, a document object of Survey.
The object docFF contains ALL the formfields in Survey.
The code tests formfields for the first question. There are both yes and no and they are named Q1_Yes and Q1_No. Pre-planning anyone....
If Q1_Yes is TRUE (checked) and Q1_No is FALSE (NOT checked), then grab the text for the appropriate bookmark (Q1_Yes) and put it into the new blank document.
Do the same for Q2 , then Q3 etc.