Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in Word adding text to top and bottom of a page when text spans pages

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
Hi Guys,

Just looking to pick some brains regarding an idea i have. For one of my current projects i am updating an exam paper generator using excel, word and vba. When in word the user clicks a button on my custom toolbar ro insert a new question. This then sets the relevant style for the question i.e question number, font etc. Currently i have no way of telling if a question goes over on to the next page until i check manually once the papers are submitted. If a question goes over 2 pages then the bottom line of the first page should read question continued on next page, and the top line of the second page should read Question x Continued (where x is the question number).

Do you guys have any ideas on if and how this could be done programmatically?

My initial thoughts would be to calculate how many lines can fit on a page and then keep track of how many lines the question has filled. I then considered using a new section for each question in the hope i could get word to use autotext or something similar to atleast put the section name and continued...however i don't think you can name a section break.

Anyone got any thoughts or ideas that might help?

Many Thanks

Jason
 
Hi,

First do it manually in the Paragraph formatting window. There's a "Keep with..." Option in there somewhere. The macro record.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
As thinking points:

Insert a wdSectionBreakContinuous section break after each question. This will bound each question between two consecutive wdSectionBreakContinuous breaks.

Use Break.PageIndex to determine if the bounding breaks for each question are on the same page or not.

 
Probably very much easier to insert a wdSectionBreakNextPage before each question - effectively causing each question to always start at the TOP of a page and start of a section.

Then use headers and footers to hold your "continued from..." and "continued on next page" messages.
 
Hi Guy's,

Thanks for the tips.

Skip i am playing around with your suggestion and i can see potential, just not 100% sure it is going to work as i would like.

Mintjulep, the issue i have with using headers and footers is that i already use them for data on the exam paper template. I have attached a copy to show the basic outline of what i am doing, it doesn't have much code in at the moment as this is my test version but you will see how it is laid out.

It's not the end of the world if what i want to happen can't happen, i mean i have taken 95% of formatting tasks away from the academics due to creating each exam paper from an excel spreadsheet list and populating the template which is then sent to them automatically for them to just add questions to.

Many thanks guys

J.
 
 https://dl.dropboxusercontent.com/u/46329287/Exam%20Paper%20New%20Template.dotm
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top