Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15  
Old 10-29-2013, 10:04 PM
fumei fumei is offline Word Template Question Windows 7 64bit Word Template Question Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

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.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word count question Wuffybrother Word 3 03-22-2019 03:40 AM
Forms in Word Question angestreck Word 0 02-15-2011 08:55 PM
Word Question - not sure how to describe CrzyIcE Word 1 04-05-2010 04:13 AM
Template path question phreeq Word 3 02-22-2010 05:08 PM
How to type on the back of word template receipts through word ??? Qintex Solutions llc Word 3 10-02-2009 07:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft