+ Reply to Thread
Results 1 to 2 of 2

Copy information from VBA userform to multiple place in a MS word template

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    The Netherlands
    MS-Off Ver
    MS Office 2003
    Posts
    1

    Copy information from VBA userform to multiple place in a MS word template

    Hello all,

    I am struggling with an issue with VBA in MS Word.

    I have a quoation template in which I would like to insert customer name, reference, sales price etc. Therefor I created a user form in VBA which pop's up when I open the word document. when I fill in the fields in the form and push the "insert" button in the userform, the macro copies the information to bookmarked places in the word document. This works fine. (see attached: test.doc)

    Now the thing is that I like to insert the same information to several places in the document. for example: the customer name is mentioned several times in the document. I understand that a bookmark can only refer to 1 place in the document.

    so my question: How can I copy the information from 1 field in the userform to multiple places in the document?
    Last edited by Jurjen Bakker; 09-11-2012 at 07:54 AM.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Copy information from VBA userform to multiple place in a MS word template

    The simplest and, in some ways, safest way to do this is to create a set of custom document properties for the customer name, reference, sales price etc, and populate those with your userform data (you can also read their values back into the userform when you re-open the document). Then, in the body of the document, you can use DOCPROPERTY fields wherever and as often as you need to display the custom document property values. Having updated the custom document properties, all you'll then need to do to ensure the document content is updated is to issue a .Fields.Update instruction.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1