none
Using Developer in Word to make templates with multiple options

    Question

  • Hello,

    I'm pretty new to Developing templates in word for use in my office. The problem I have is that our company has four branches, and we only want one address to show up on the completed document without the user needing to type in the address. Is there a way to use the drop down list content control tool to change between four different 'paragraphs' rather than simply one line values?


    Tuesday, November 20, 2012 9:37 PM

All replies

  • Hi Heather2222,

    Thanks for posting in the MSDN Forum.

    I think you need clarify your goal more detailed. Do you want set a combo box at the document's header and change specific texture in the document when it's selection has been changed?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 22, 2012 7:26 AM
    Moderator
  • Hi Tom,

    I guess that would be a good solution to my problem, so that if the user chooses 'branch 1', the corresponding address will show up below it. All will be within the body of the document, not in the header. I haven't been able to figure out how to set that up though. How do you link the text to the choice?

    thanks!

    Thursday, November 22, 2012 7:58 PM
  • Hi Heather

    A better approach might be to use the BuildingBlock content control? Then you could save the addresses in a particular Gallery and Category, set the content control to show entries in that Gallery + Category combination and the user would choose the appropriate entry.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, November 23, 2012 5:18 PM
    Moderator
  • Hi Cindy,

    thanks for the help. I inserted a building block with the different addresses saved in the quick parts gallery, however when I enforce protection, the drop down box is greyed out and I can't make a selection from the added options. Am I doing something wrong?

    Monday, November 26, 2012 6:56 PM
  • Hi Heather

    First time you mention document protection... So, exactly what kind of protection is this?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, November 27, 2012 8:25 AM
    Moderator
  • I just mean that when you are making a template using the developer tab, in order that the person using the template, I understood that you should open the 'restrict editing' sidebar and click on 'yes, start enforcing protection'. Otherwise the person using the template is able to mess up the formatting. If I save the document without clicking the enforce protection button, it is possible to make a choice, but it is also possible to move the box or anything else. Is there a way to block formatting changes while still being able to make a choice from the quick parts menu?

    thanks

    Tuesday, November 27, 2012 5:07 PM
  • Hi Heather

    That task pane supports four different kinds of protection; each has different ramifications. Look at Step 2 in that "sidebar" (task pane) and tell us what it says.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, November 27, 2012 6:18 PM
    Moderator
  • Hi,

    it says Allow only this type of editing in the document - and then in the drop down I have Filling in Forms

    thanks

    Tuesday, November 27, 2012 10:39 PM
  • Hi Heather

    Thank you for the additional information. Yes, filling in forms won't allow anything that could be formatted - it's plain text only. As a building block might be pulling in formatting, that's a problem.

    In this case, there are two basic approach available:

    1. Place continuous section breaks before and after the address area and format the section this creates as "not protected". But, as that implies, the user would be able to make other changes.

    2. Associate macro code with a dropdown that will: unprotect the document, insert the appropriate address, reprotect the document. Recording a macro should get you the basic syntax for those steps, especially the first and the last. Note that the macro cannot trigger when a selection is made, but only when the user exists the field.

    A variation on this would be to display a UserForm when the user enters the field that offers the selections. When the user "OKs" the UserForm that code does the steps outlined above. It's a bit more "intuitive" than the above as the user doesn't need to consciously exit the field.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, November 29, 2012 4:48 PM
    Moderator
  • Thanks Cindy,

    I tried the first option, and for some reason it still won't let me choose from the dropdown menu of the building blocks. I left that section unprotected, but the button is still greyed out. I also don't want to make a macro (mostly because I think it'll be too hard to share with the users of the file, and because I haven't been able to figure out how to get one running successfully, I'm sick of trying).

     I think I may just have to leave the entire document unprotected, and hope that people using the file don't mess up the formatting too much, it shouldn't be too much of a problem.

    Thank you very much for your help,

    Heather

    Thursday, November 29, 2012 8:54 PM
  • Hi Heather

    See this KB article about how to create a macro that will trigger when the user enters a form field to show a UserForm.

    Note that forms protection disallows using the BuildingBlocks content control. So you'll have to provide a list of addresses (or recipients or whatever makes sense when the user sees it). The macro will then insert that entire information.

    You need to consider where the best place would be to store the addresses. They could be hard-coded into the macro, which would make the macro simpler but maintenance of the addresses difficult. They could be stored as AutoText entries (BuildingBlocks) or in any kind of file.

    Since you're building a template the macro would be IN the template. So whoever can use the template will automatically have access to the macro.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, December 10, 2012 3:47 PM
    Moderator