Question

I need to set the margins differently for the first page than the rest of the pages.

I've messed around with inserting section breaks (as from what I've read is that Word creates a section break when you choose to apply "this point forward" from the Page Setup Margins tab, but I can't seem to consistently create a continuous section break at the start of the second page.

If not section breaks, any other way would be fine. Need to adjust margins to match new letterhead design for a bunch of existing documents so am planning on fixing the margins in a sub-routine when the print button is clicked (part of another macro).

Was it helpful?

Solution

A Continuous Section Break is used to allow multiple sets of margins within the same page. A Next Page Section Break, which has the properties of both a section break and a page break, will allow one set of margins for the first page and another set of margins for all pages following it. One way it can be created is like this:

Selection.InsertBreak Type:=wdSectionBreakNextPage

Now here's where it gets tricky. Word has two different types of page breaks: Automatic and Manual. Automatic page breaks get created when text no longer fits on a page and Word automatically generates a new page. If the documents you are reformatting via the macro have automatic page breaks, inserting the Next Page Section Break at the end of the first page will cause Word to delete its Automatic Page Break (using the Next Page Section Break to keep the pages separate) and any margin changes you make to the first page will not carry over to the following pages. However, if the documents contain a Manual Page Break between pages one and two, inserting the Next Page Section Break will create a blank second page. As such, if this is a possibility, code will need to be written to detect the Manual Page Break and delete it after the Next Page Section Break has been inserted.

OTHER TIPS

Letterhead layouts and Word can be really difficult and tricky if you need other values only on the first page. In my practice, I find often letterheads with graphical elements in a right margin of the first page up to a certain heigth, e.g. a list of partner names or business information. So on the first page the right margin should be 6 cm, while on all following pages it should be 2,5 cm. Using a section break is not possible due to the fact that it moves while the user inserts text.

I've used the following approach with some success: Create a text box in the first page header which is sufficiently big to occupy the space needed. Setup the property for "Text Wrapping" = Square, so that text cannot overlap the box. Of course you can insert the text box also into the document body to have that effect. Unfortunately, users can then touch the text box easily in a mouse action, and move it to another position. If you put it into the first page header, it will appear only on the first page, and will appear "in the background" of the page. The user can enter text in the document body, but it will stop before the text box, which simulates a right margin on the first page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top