- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All Topics Most "reports" are multiple pages which have the same format - I have tons of those examples. However, in the telecommuncations industry we have reports in which EVERY page of a multi page report is drastically different.
I have templates (*.dot) files of each page. I'm trying NOT to append all the *.dot files into one big template - I would like to refer to each template separately.
QUESTION: How do I write a VB app to automatically generate a report which requires referencing a template for each page?
I'm so desperate, I'm willing to save each sheet in a separate file and append them at the end if I have to.
I don't want to destroy and restart the Word.Application every time for each customer due to the time to start/destroy/start the Word.Application.
EXAMPLE: I can get the first sheet created o.k. But I get error '5151' when the second "docReport" is instantiated. Of course this example is merely pseudo-code to demonstrate my problem.
==========================
Dim fileTemp(8) as String
fileTemp(1) = "Normal.dot"
fileTemp(2) = "Special2.dot"
... ...
fileTemp(8) = "Special8.dot"
Dim WordApp as Word.Application
Dim docReport as Word.Document
Set WordApp = New Word.Application
For i = 1 to TotalCustomers
Call GetCustomerDataFromDataBas
For j = 1 to 8 ' form has 8 different sheets
Set docReport = Documents.Add Template:=fileTemp(j)
Call PopulateBookMarks(fileTemp
ActiveDocument.SaveAs fileName:= outputFile
ActiveDocument.Close
Set docReport = Nothing
Next j
Next i
==========================
Any pointers would be greatly appreciated.
This question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership