If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Advice on Inserting Text Dependent on Formfield/Content Control

I'm seeking some advice on how best to approach this situation. I'm sure it's quite common.

I'm automating the preparation of a two page document in Word 2007.

Page one contains various data that I've chosen to place in ContentControls. The second Page is a unique full page of "terms and conditions" dependent on one of three possible choices in a drop down content control on the first page.

My question is how to best approach this from a programming point of view. Ideally, I'd like to distribute one .dotm file from which these documents will be created. At the end of the document creation process, I intend to save the completed 2-page document as a PDF.

Should I store each of the three possible "Second Pages" in the template file and then upon the content control changing, move the appropriate page into the second page position, and then only save the first two pages as the PDF? Or somehow make them visible based on the selection in the content control, while keeping the other ones hidden?

Or do I need three separate supporting files, which I would choose from to append to the first page to create the whole document?

Just looking for some professional advice on how best to approach this scenario.

Thanks for all the input here. I'm started to gain a much deeper appreciation for Word's power.

Along the lines of having everything in there to begin with and then removing them, I had run that through my mind and thought that might not be a good idea in my case.

For example, if the required text was a function of the selection in a drop down control, what if the user changed their selection? Had you already "removed" all but the required bit for the earlier choice, how would you be able to "reveal" the newly required choice?

Toggling visibility with the Font property would work I guess. From what I understand so far however, I think I'm liking the sounds of the Building Blocks Gallery, and the Autotext. As I understand it, that would allow you to store all the possible Ranges of text as elements of the AutoTextEntries collection, and then use them when and where needed with no (little) risk of the user inadvertently deleting something that might be needed later.

Thanks again for all the great input! I've got a long way to go on really being able to leverage Word.

And I concur. However, you mentioned the user changing their selection.

You still have the same issue, regardless of whether it is inductive (adding via AutoText or BuildingBlocks), or deductive (removing via bookmarks).

If they make a selection, and that causes the insertion of content via AutoText, then once it is inserted it is NOT identified as such. It becomes just like any other chunk of text. That is, unless you explicitly make it identified.

Other BuildingBlock content...well, I will let Greg handle that.

On the other hand, if it is an adding (even with "ordinary" AutoText), and it is inserted at a bookmark, then it IS identifiable, and can be removed if the user changes the selection of the driopdown.

Building Block Gallery

Keith,

You could certainly use a dropdown CC on page 1 and a buildiing block gallery CC on page 2.

First create your builiding blocks (the chuncks of text to appear on page 2). For this example lets save them in the template using the Custom1 gallery, a new category "Demo", with Titles "One, Two and "Three."

Add a dropdown CC on page one and name it "Pick." Add the list entries "One, Two, and Three"

On page 2 insert a building block gallery and set its properties to Custom1 Gallery, Category "Demo" title "Picked"

Actually I think just a rich text control named "Picked" would do just as well in this case.

Originally Posted by hred Dude

Thanks for all the input here. I'm started to gain a much deeper appreciation for Word's power.

Along the lines of having everything in there to begin with and then removing them, I had run that through my mind and thought that might not be a good idea in my case.

For example, if the required text was a function of the selection in a drop down control, what if the user changed their selection? Had you already "removed" all but the required bit for the earlier choice, how would you be able to "reveal" the newly required choice?

Toggling visibility with the Font property would work I guess. From what I understand so far however, I think I'm liking the sounds of the Building Blocks Gallery, and the Autotext. As I understand it, that would allow you to store all the possible Ranges of text as elements of the AutoTextEntries collection, and then use them when and where needed with no (little) risk of the user inadvertently deleting something that might be needed later.

Thanks again for all the great input! I've got a long way to go on really being able to leverage Word.

And I concur. However, you mentioned the user changing their selection.

You still have the same issue, regardless of whether it is inductive (adding via AutoText or BuildingBlocks), or deductive (removing via bookmarks).

If they make a selection, and that causes the insertion of content via AutoText, then once it is inserted it is NOT identified as such. It becomes just like any other chunk of text. That is, unless you explicitly make it identified.

Other BuildingBlock content...well, I will let Greg handle that.

On the other hand, if it is an adding (even with "ordinary" AutoText), and it is inserted at a bookmark, then it IS identifiable, and can be removed if the user changes the selection of the driopdown.

The point being is you have to really think this through.

Gerry:

Thanks for the feedback.

I have a question about your comment on not being able to identify the text after it's been placed in the document, unless at a bookmark.

What about ContentControls? It seems I can get to that text.
[VBA]
?activedocument.SelectContentControlsByTag("testdata").Item(1).Range.Text
12345

Reading through these forums I find much less posted on Content Controls than other methods. I'm new to doing more in depth stuff in Word, and as such have grabbed onto the "newer" stuff I guess. Maybe I just like the way the Content Controls look.

Am I constraining myself by using them in a template as opposed to Bookmarks, for example to designate the destination(s) for text I'd be bringing in programatically from other sources?

Maybe I'm still thinking of Templates in a less than ideal way. If I only want to use the template to create a document programatically, then no value to the visual nature of the ContentControls I guess. But, if I want to throw a bunch of data onto a form via code, and then let the user cruise around on it and make some edits before wrapping things up, then the Content Controls seem like a good thing. You can put descriptive Titles on them, but still have a concise Tag property to use in code, can do Date Pickers, and as I'm just beginning to learn more about can have Building Block Galleries to select from.

Are the Content Controls just not as widely adopted as Bookmarks, or are there some serious limitations I'm not seeing?

CCs were introduced with Word2007. Like me in many ways, many people resist change. A bookmark is a defined range in a document so is a content control. While the methods are different, whatever you can do with a bookmark your can pretty much do with a CC. There are a few exceptions and the overall advantage that CCs has over a bookmark it that it has more properties.