none
Word 2010 User Form - Repeating data

    Question

  • Hi:

    I am a novice developer in Office. My focus at this time is Word 2010. I have developed a Word 2010 Template, placed text bookmarks, designed the "user input form" in VB and coded the fields I believe appropriately.

    I am stumped on how to make the bookmarks in the Word template or the User Form Fields (content controls) in the Form repeat/populate information in other bookmarks that is initially put into one field of the screen presentation of the User Form. Example: "Supplier Name" field needs to populate three different places in the Word Template document. I have done some research as to REF fields but I am not sure if that is what I need to do or even how to do that if it is? When I experimented some of the bookmarks (with same name) in my template disappeared. I have found information regarding the design of filling in fields in the Template itself by Greg Maxey who also refers to articles by Suzanne Barhhill, but I can't seem to grasp how this might be applied to my needs? Any assitance would be greatly appreciated. The users want to have the graphical form presentation instead of a template document with the field controls in it for filling in.

    Thanks

    Maree Percival

    Thursday, May 27, 2010 2:56 PM

Answers

  • If by Graphical Form presentation, you mean what I think you do, you should look at the following page of Greg Maxey's website:

    http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

    and use DocVariable fields instead of bookmarks. The advantage of that is that there is no limit to the number of DocVariable fields that you can have for the one variable.

    --
    Hope this helps.

    Please reply to the newsgroup unless you wish to avail yourself of my
    services on a paid consulting basis.

    Doug Robbins - Word MVP, Posted via the NNTP Bridge
    "Maree Percival" <a4369d05-e022-441e-91f0-35d0fc707b06@invalid.com> wrote in message news:f55582b8-6996-4a56-aec1-2ad7a4144e8e@communitybridge.codeplex.com...
    Hi Cindy - thanks for helping me out on this, I got a little further today and found some of my own mistakes, but I am still not clear on the process.

    1. Do I put a bookmark where the next duplicate information areas are in the document or just place the REF field there? I am understanding that I should just place a REF field in the following placement of the same information instead of a "Bookmark + REF" field?

    2. Above you had mentioned that I need to "surround" the Bookmark - not quite sure what that means?

    3. I have two methods of placing bookmarks, one is to select a blank space and insert the bookmark so it shows on screen as [] or just the placement where is should go and shows as I? They both seem to work.

    I apologize for not being able to understand all of this well - this is the first form I have done in Word using VB. I promise I will do some classes soon.

    Hope you have a nice Memorial weekend.

    Maree


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Saturday, May 29, 2010 8:58 AM
  • 1. File→Option→Costomize Ribbon→Check on the “Developer” (to unhide the developer tab on the toolbar)

    2. Developer→RichText Content Control or Plain Content Control (the one with the Aa icon) to create a Content Control box which you can fill any text like a form.

    3. Right Click on the Content Control to Copy it.

    4. Paste it where ever you need it, but don’t use the right click or ctrl+v to paste it.

    5. Home→Paste→Paste Special→Paste link.

    6. Viola... any text you enter in the master Content Control will paste to the rest.

    Thursday, September 05, 2013 3:14 AM

All replies

  • Hi Maree

    Note: I'm unsure about what you mean by "content controls" in your problem description. Content Controls are used on a document, not in a UserForm. So I may be mis-understanding some things...

    If you're writing data from the UserForm into bookmarks, then you would write it to one bookmark and insert a Cross Reference to that bookmark. (Inserting a cross reference inserts a REF field in the background). When the fields in a document are updated, the REF field will reflect the content of the bookmark (you can see this using Ctrl+A, F9). The key point to this is that the bookmark must surround the text. It can't be next to the text - it has to surround the text.

    The other approach (and I think that's what you mean when you refer to Greg Maxey's article) would be to insert Content Controls on the document (instead of bookmarks), write the data to them, and make sure they're mapped to a CustomXMLPart in the document. All content controls mapped to the same element in the CustomXMLPart will display the same text.

    Which approach you should choose depends primarily on two things:

    1. Do you expect users to edit the document? If yes, is it a concern that they might delete such a "target field" (bookmark or content control)

    2. Do you feel comfortable enough with both methods to not care which you use?


    Cindy Meister, VSTO/Word MVP
    Thursday, May 27, 2010 5:10 PM
  • Thank you for your response Cindy - I will try what you suggest and utilize the REF field, however, I am not sure where the REF would be put in, is it done by:

    Selecting the Bookmark, choose Quickparts, choose Fields, choose Links and References, choose Ref, choose the "Supplier" bookmark name?

    If I choose REF on the 2nd bookmark that needs to populate with the same text as the first I get an error Error! Reference source not found.,! Then the "Supplier" bookmark is deleted out of the list when I go to choose it again.

    Maree

    Thursday, May 27, 2010 7:22 PM
  • Thank you for your response Cindy - I will try what you suggest and utilize the REF field, however, I am not sure where the REF would be put in, is it done by:

    Selecting the Bookmark, choose Quickparts, choose Fields, choose Links and References, choose Ref, choose the "Supplier" bookmark name?

    If I choose REF on the 2nd bookmark that needs to populate with the same text as the first I get an error Error! Reference source not found.,! Then the "Supplier" bookmark is deleted out of the list when I go to choose it again.


    Hi Maree

    You can use the dialog box you're asking about but...

    Do NOT first select the bookmark. If you do that, inserting the REF field will delete the bookmark. (And that's the reason it disappears from the list the second time.)

    Position the cursor where you want to have the duplicated information displayed and insert the REF field there.


    Cindy Meister, VSTO/Word MVP
    Friday, May 28, 2010 4:05 AM
  • Hi Cindy - thanks for helping me out on this, I got a little further today and found some of my own mistakes, but I am still not clear on the process.

    1. Do I put a bookmark where the next duplicate information areas are in the document or just place the REF field there? I am understanding that I should just place a REF field in the following placement of the same information instead of a "Bookmark + REF" field?

    2. Above you had mentioned that I need to "surround" the Bookmark - not quite sure what that means?

    3. I have two methods of placing bookmarks, one is to select a blank space and insert the bookmark so it shows on screen as [] or just the placement where is should go and shows as I? They both seem to work.

    I apologize for not being able to understand all of this well - this is the first form I have done in Word using VB. I promise I will do some classes soon.

    Hope you have a nice Memorial weekend.

    Maree

    Friday, May 28, 2010 9:36 PM
  • Hi Maree

    1. The bookmark goes in the first place in the document where you want to see the information from the UserForm. The REF field goes in every other place in the text where the information should appear.

    Note that the REF field may not immediately show the information after it has been written to the bookmark. Most fields need to be updated explicitly. If this is happening to you, press Ctrl+A, then F9 to force all the fields in the document to update, to see if you're getting what you expect. This can be done with your code using the .Fields.Update method, which you need to use with your Document object. (Something like oDoc.Fields.Update)

    2. & 3. It means this kind of bookmark: [ ]

    But you have to be careful to recreate the bookmark around the text you insert. If you insert text into a bookmark: oDoc.Bookmarks("Name").Range.Text the bookmark will be deleted. So a REF field won't work correctly.

    Your code needs to be more like, to recreate the bookmark after the text has been added

    Dim rng as Word.Range
    Set rng = oDoc.Bookmarks("Name").Range
    rng.Text = "the new text"
    oDoc.Bookmarks.Add Range:=rng, Name:="Name"


    Cindy Meister, VSTO/Word MVP
    Saturday, May 29, 2010 8:31 AM
  • If by Graphical Form presentation, you mean what I think you do, you should look at the following page of Greg Maxey's website:

    http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

    and use DocVariable fields instead of bookmarks. The advantage of that is that there is no limit to the number of DocVariable fields that you can have for the one variable.

    --
    Hope this helps.

    Please reply to the newsgroup unless you wish to avail yourself of my
    services on a paid consulting basis.

    Doug Robbins - Word MVP, Posted via the NNTP Bridge
    "Maree Percival" <a4369d05-e022-441e-91f0-35d0fc707b06@invalid.com> wrote in message news:f55582b8-6996-4a56-aec1-2ad7a4144e8e@communitybridge.codeplex.com...
    Hi Cindy - thanks for helping me out on this, I got a little further today and found some of my own mistakes, but I am still not clear on the process.

    1. Do I put a bookmark where the next duplicate information areas are in the document or just place the REF field there? I am understanding that I should just place a REF field in the following placement of the same information instead of a "Bookmark + REF" field?

    2. Above you had mentioned that I need to "surround" the Bookmark - not quite sure what that means?

    3. I have two methods of placing bookmarks, one is to select a blank space and insert the bookmark so it shows on screen as [] or just the placement where is should go and shows as I? They both seem to work.

    I apologize for not being able to understand all of this well - this is the first form I have done in Word using VB. I promise I will do some classes soon.

    Hope you have a nice Memorial weekend.

    Maree


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Saturday, May 29, 2010 8:58 AM
  • 1. File→Option→Costomize Ribbon→Check on the “Developer” (to unhide the developer tab on the toolbar)

    2. Developer→RichText Content Control or Plain Content Control (the one with the Aa icon) to create a Content Control box which you can fill any text like a form.

    3. Right Click on the Content Control to Copy it.

    4. Paste it where ever you need it, but don’t use the right click or ctrl+v to paste it.

    5. Home→Paste→Paste Special→Paste link.

    6. Viola... any text you enter in the master Content Control will paste to the rest.

    Thursday, September 05, 2013 3:14 AM