• UserForms & bookmarks vs. Content Controls vs. DocVariable

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » UserForms & bookmarks vs. Content Controls vs. DocVariable

    Author
    Topic
    #494636

    Hi All,

    I have a userform and want to put the data from that form into about 5 different documents.

    Nothing too special about that, and many years ago I did it with bookmarks.

    I want to do something similar again, but I understand that times have changed, and my requirements this time are slightly different:

    1. A userform that prompts for a variety of data, and then populates several documents (we call these documents a “form set” – there is a form set created for each “case”).

    2. The form set that is created is a bit of a living document, in that after its been created it is saved to a folder on a network share for that “case” and may be opened, data change and then resaved until the case is closed.

    So when the form set is reopened, ideally the userform wants to be displayed again, and still be populated with the data that was originally entered. This data, once edited should update the forms.

    3. A later stage of the project may do things in the background like sending emails.

    So of the methods listed in the subject line, which is best before I start to get my hands dirty? Plan on starting in Word 2007 but will be on Word 2013 pretty soon.

    Thanks in advance,

    -Al

    :huh:

    Viewing 5 reply threads
    Author
    Replies
    • #1452046

      Al

      Each option has a significant drawback so whichever method you choose will have some repercussions.

      I personally go the Content Control way now but this functionality will degrade if the document is going to be saved to Doc format. The big benefit of the Content Controls is that a userform and macros is an optional extra and may not be necessary for the end users. However, you will need macros and/or the Content Control Toolkit to do the setup linking the xml fields to each Content Control. The common doc property fields (Insert>Quick Parts>Document Property) allow you to avoid this complexity but you will rapidly run out of fields.

      The DocVariable or alternatively, Custom Document Property methods would be more robust in the case of saving to doc format but it has the drawback of requiring macros to edit the document fields.

      Bookmarks + userform and macros might also work for you but will require a bit of fiddling to find bookmarks and mapping to userform fields when the field needs to appear in multiple locations. Bookmarks are pretty fragile and susceptible to users editing the content without paying attention to the ‘bookmark’ ranges.

      Since you want to save the field entries to multiple output documents then I would guess you can’t really avoid using end-user macros especially if you want subsequent edits to fields to be replicated across documents. You could get creative to stay with a single document and use building blocks to display each of the customised documents on demand – leveraging the same custom xml or document properties.

      • #1452051

        Al

        Each option has a significant drawback so whichever method you choose will have some repercussions.

        I personally go the Content Control way now but this functionality will degrade if the document is going to be saved to Doc format. The big benefit of the Content Controls is that a userform and macros is an optional extra and may not be necessary for the end users. However, you will need macros and/or the Content Control Toolkit to do the setup linking the xml fields to each Content Control. The common doc property fields (Insert>Quick Parts>Document Property) allow you to avoid this complexity but you will rapidly run out of fields.

        No problem with backward compatability so will use contentcontrol.

        Al
        Since you want to save the field entries to multiple output documents then I would guess you can’t really avoid using end-user macros especially if you want subsequent edits to fields to be replicated across documents. You could get creative to stay with a single document and use building blocks to display each of the customised documents on demand – leveraging the same custom xml or document properties.

        Are you saying it would be easier to have multiple forms/templates within the one document/file? I can live with this if its easy to “jump” to each page for the end user (is this done via building blocks?)

        I have taken a good look at Greg Maveys site, he explains a lot about contentcontrols, and it seems as if you don’t need a VBA userform – it looks like most of the time he enters straight into the document?

        Personally I prefer a VBA userform, but I don’t know enough about contentcontrols to be make a informed decision?

        I also haven’t seen yet how to insert one item, say Case name into multiple places in the document?

        Regards

        bigAL 🙂

    • #1452055

      gAl 😉

      I think it is a lot easier to hold all the ‘forms’ in the same document. This means you can write the variable data once and then the relevant CCs appear wherever they are needed. Adding Content Controls to your form is the easy part. The trick to getting related content controls to display the same text (eg Case name) is to map those content controls to the same xml element. I use the Content Control Toolkit to do this but you can also do it using code that Greg Maxey has provided on his site.

      Editing the text in a mapped CC changes the value of the text in the custom xml document and hence any CC mapped to that xml element will automatically display that same text. It is also possible to alter the underlying xml file directly or via a macro but a mapped CC is the least painful way of modifying each xml element since it is sitting on the page.

      If you think that it is too hard for users to hunt down each CC in your documents, you can include a temporary data entry form at the top of the document so the user can complete all the relevant information (which writes to the underlying xml) and then they can delete that data entry form to leave behind the completed forms.

      If you create each of the forms with the mapped CCs, you can then save them individually into building blocks (Autotext or Quick Parts for example). Your data entry form could also be saved as a building block to allow the author to revisit all the fields anytime they need to. Once the custom xml has been saved (by editing a mapped CC), you can add any of the stored building blocks to see the completed form(s).

      • #1452057

        gAl 😉

        I think it is a lot easier to hold all the ‘forms’ in the same document. This means you can write the variable data once and then the relevant CCs appear wherever they are needed. Adding Content Controls to your form is the easy part. The trick to getting related content controls to display the same text (eg Case name) is to map those content controls to the same xml element. I use the Content Control Toolkit to do this but you can also do it using code that Greg Maxey has provided on his site.

        Ok, so one document. I guess the first page, could simply be the “data collection” page which would host a bunch of fields which then distribute the information as required (some bits of information goes to some forms but not others etc).

        I assume there is a way to have a CC that will accept data that would be normally store in a list, ie a list of people and addresses associated with a case?

        I will get the CC toolkit and play around with it.

        If you think that it is too hard for users to hunt down each CC in your documents, you can include a temporary data entry form at the top of the document so the user can complete all the relevant information (which writes to the underlying xml) and then they can delete that data entry form to leave behind the completed forms.

        If you create each of the forms with the mapped CCs, you can then save them individually into building blocks (Autotext or Quick Parts for example). Your data entry form could also be saved as a building block to allow the author to revisit all the fields anytime they need to. Once the custom xml has been saved (by editing a mapped CC), you can add any of the stored building blocks to see the completed form(s).

        Not really quite up to speed on building blocks. I have a vague idea of what they are.

        I did like the way this navigation was displayed:

        36949-navigation

        I guess its getting close to diving in!

        -Al

    • #1452065

      There are different types of CCs. One is a drop-down list so you can choose from the list. As far as I can tell the list is added to the content control itself – I don’t think you build the list in an xml schema although that would make more sense.

      Building blocks are a way of storing content in a ‘library’ so you can insert that content anywhere in the document. This used to be known as Autotext and essentially it hasn’t changed but there are now categories and subcategories which allow other functionality to appear.

      That navigation in your screen capture is basically just a list of headings in your document that can be clicked on to jump around the document. If you use headings in your forms you will be able to show this navigation pane.

      • #1452066

        There are different types of CCs. One is a drop-down list so you can choose from the list. As far as I can tell the list is added to the content control itself – I don’t think you build the list in an xml schema although that would make more sense.

        Sure, but any person could be in the list of people – its not a discrete list, so it almost wants to be a table that always has a extra row you can add or something.

        Sometimes there will be two people, sometimes twenty….

        Each person will have Name, Address, Phone Number – so its a multi column list of people that needs to be stored.

        Hope that makes sense, how will I deal with this?

        Cheers for your replies.

        Al

      • #1452075

        Possibly something like this for the list of people?

        http://gregmaxey.mvps.org/word_tip_pages/add_map_employ_RSCC_Word_2013.html

    • #1452078

      That page is describing a feature relevant only to Word 2013. The repeating row functionality is not available in the earlier versions of Word AFAIK.

      Look on the Developer Tab for the Combo Box Content Control and then click the properties button to add entries to the list.

      • #1452144

        Hi Andrew,

        Thanks. I played with Combo Box Content Control, but that looks like the developer populates the list, and then the user can select items from the list.

        In this case, the developer wont know what people to put in – I need a content control that “asks” for the list of people – could be 10 people, could be 3 people. Each case will involve differnet people, and different numbers of people.

        Is there a CC for this?

        36953-Untitled

        -Al

    • #1452187

      If the author is providing the list then you may feel the push towards only using Word 2013 and following the guidance of Greg Maxey’s page that you already posted.

      In Word 2007, you could either build the form with the maximum possible number of records and just allow the user to leave the later ones empty. You could maybe use a macro to hide the rows that aren’t needed. Alternatively, you could use a macro to allow the user to add a new record (stored as a quick part and inserted by the macro). You would need to change the mapping of the CCs in that record but that is simple enough with a macro.

    • #1452392

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    Viewing 5 reply threads
    Reply To: UserForms & bookmarks vs. Content Controls vs. DocVariable

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: