
Tips.Net > WordTips Home > Formatting > Templates > Templates and Page Setup
Summary: Templates are a great way to share styles, macros, and other settings among various documents. One thing that isn’t shared through templates, however, is page setup. If you want to have this shared, you’ll love the macro presented in this tip. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
Other issues of WordTips have addressed how to use templates. Templates are nothing but special collections of styles, macros, toolbars, and other "goodies" that define your Word environment. You can change how a document looks by simply changing the template attached to the document and then applying styles, as necessary. You change the template attached to a document by using the Templates and Add-ins dialog box. (Click here to see a related figure.) You display this dialog box in the following manner:
When you change templates on a document, not everything from the new template is applied to the document. For instance, the page setup for the template is not applied to a document. This can be frustrating, until you realize that applying it could create quite a few problems. Why? Because page setup information, within Word, is a function of sections. This means that you can vary page setup for each section defined in your document. When you attach a new template to a document, how is Word supposed to know which section's page setup should be overwritten? If it applies the page setup from the template to all the sections in the document, then you could lose quite a bit of work.
There is no such problem, however, when you are first creating a document based on a template. In this case, the new document is simply a reflection of the entire template document.
With this understanding, if you still want to apply the page setup information from a template to the current document, you can do it rather easily using a macro. The following macro can serve as your guide:
Sub ApplyTemplatePageSetup()
Dim Tmpl As String
Dim CurDoc As Document
Tmpl = ActiveDocument.AttachedTemplate
Set CurDoc = ActiveDocument
Documents.Add Template:=Tmpl
With CurDoc.PageSetup
.LineNumbering.Active =
ActiveDocument.PageSetup.LineNumbering.Active
.Orientation = ActiveDocument.PageSetup.Orientation
.TopMargin = ActiveDocument.PageSetup.TopMargin
.BottomMargin = ActiveDocument.PageSetup.BottomMargin
.LeftMargin = ActiveDocument.PageSetup.LeftMargin
.RightMargin = ActiveDocument.PageSetup.RightMargin
.Gutter = ActiveDocument.PageSetup.Gutter
.HeaderDistance = ActiveDocument.PageSetup.HeaderDistance
.FooterDistance = ActiveDocument.PageSetup.FooterDistance
.PageWidth = ActiveDocument.PageSetup.PageWidth
.PageHeight = ActiveDocument.PageSetup.PageHeight
.FirstPageTray = ActiveDocument.PageSetup.FirstPageTray
.OtherPagesTray = ActiveDocument.PageSetup.OtherPagesTray
.OddAndEvenPagesHeaderFooter =
ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter
.DifferentFirstPageHeaderFooter =
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter
.SuppressEndnotes = ActiveDocument.PageSetup.SuppressEndnotes
.MirrorMargins = ActiveDocument.PageSetup.MirrorMargins
End With
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Set CurDoc = Nothing
End Sub
This macro determines the template in use, creates a new document based on that template, and then copies the page setup information from the new document to the original one. When completed, the new document created by the macro is deleted. You can delete any portions of the macro that you don't feel are applicable. For instance, if you only wanted to change the margins to match your template, all you need to keep in this macro are the four lines that set the margins.
Obviously, this macro overrides any page setup information in your document. (This is the original idea, right?)
Tip #1815 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Great Idea! Uncover the many ways you can master the full potential of printing your documents. WordTips: Printing and Printers can help you get the most from both the printed page and your printer.
Learn to search for and replace text, formatting, graphics, and special characters the easy way with WordTips: Find and Replace. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips