Solved

Winword doc from template - use the template for multiple pages

Posted on 2016-11-10
3
61 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

623 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