Solved

Winword doc from template - use the template for multiple pages

Posted on 2016-11-10
3
34 Views
Last Modified: 2016-11-14
I've got a winword document I create from a template and fill in details via automation from an access database using VBA and bookmarks in the word doc.  The automation code exists and works.  
Now I would like to create a second (or further) page based on the template with some of the information/bookmarks being duplicated.  This new function might be required once a year or less often so a complete rewrite isn't going to happen.

eg. At the top of each page I would want the customer name, address and an ID to be duplicated.  Remember the information is pushed into the document when it is created in response to a button click.

I can think of creating a new document for page two, filling it in then select all and copy/paste into the first document as a new page.  It should work but is really cludgy.
Is there an easier way to do this?
0
Comment
Question by:AndyAinscow
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 41882777
You probably realise that you can't copy bookmarks directly. All bookmarks in a document must be uniquely named. Your idea of using a separate document would be one way around that problem.

Other solutions might require some redesign of your original system.

You could use REF fields to repeat the data in the bookmarked locations.

You could put the customer information in the document header, so that it is reproduced on all pages, If you only want it in the second and subsequent pages, you could have a different first page and the information in the prime header.

If you don't need to support Word versions older than 2007, you could use content fields. These can be copied, the copies retaining the Tag and Title properties. There are  SelectContentControlsByTag and SelectContentControlsByTitle that give collections that can be walked through.

It might help if you could post a non-confidential example.
0
 
LVL 44

Author Comment

by:AndyAinscow
ID: 41882817
Thanks, I wasn't really expecting a simple way but would kick myself if there was and I didn't explore for it.
Interesting idea with the ContentFields.  I'll have a look into that.  It is only 'newer' versions of word involved.
0
 
LVL 44

Author Closing Comment

by:AndyAinscow
ID: 41887381
Thanks.
I'll be going with my original idea of a new doc, copy and paste to page 2....  I think it will be less changes required
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now