AngelofDev.com

Where I go to AFK

Menu
  • Home
  • How To
    • VBA
  • KOA:DW / GOG
    • Tips & Tricks
    • Tools & Calculators
  • Minecraft Plugins
  • King Tools for KOA & GOG
  • Outlast: Asteroid Defense
  • King of Avalon Player Stats Tracker
Menu

How to Create Microsoft Word Document/Template with Different Margins on the First Page

Posted on June 18, 2018June 19, 2018 by admin

Below are two alternative ways of creating a Microsoft Word document/template with different margins on the first page.

Here’s a super easy way.

This method is ideal for one off documents.

  1. Insert a Section Break (Next Page) from Page Layout > Breaks
  2. Click on the page you want to expand/narrow the margins.
  3. Click on Custom Margins from Page Layout > Margins
  4. In the Page Setup window put in the custom margin size you want then click OK.

Here’s a super hard way.

This method inserts a new page with an adjusted margin when the document is first opened, however requires your document to be a macro enabled workbook.

It also checks if the second page has been deleted if so it readjusts the margin of the first page.

  1. Setup your first page how you want it with the correct margins.
  2. Create a macro with the below code, sections of code to pay attention to are commented with ‘CHANGE THIS’:

Code:

Sub Document_Open()
    If ActiveDocument.Sections.Count > 1 Then Exit Sub

    Selection.EndKey Unit:=wdStory
    ActiveDocument.Range(Start:=Selection.Start, End:=Selection.Start). _
        InsertBreak Type:=wdSectionBreakNextPage
    Selection.Start = Selection.Start + 1

    With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _
        Content.End).PageSetup
        .LeftMargin = CentimetersToPoints(2.54) 'CHANGE THIS it's margin of new pages!
        .SectionStart = wdSectionNewPage
    End With

    Application.OnTime When:=Now + TimeValue("00:00:01"), _
    Name:="CheckPages"

End Sub

Sub CheckPages()
    Application.OnTime When:=Now + TimeValue("00:00:01"), _
    Name:="CheckPages"

    If ActiveDocument.Sections.Count = 1 Then
        ActiveDocument.PageSetup.LeftMargin = CentimetersToPoints(5.54) 'CHANGE THIS it's margin of the first page!
    End If

End Sub
  1. Save your document.
  • margins
  • microsoft-word
  • vba
  • vba-code
  • Word
  • Recent Posts

    • How to add Fantom’s SCREAMO NFT to MetaMask Wallet November 1, 2021
    • How I determine which cryptocurrency assets to invest in. May 23, 2021
    • Cryptocurrency Staking Calculator May 20, 2021
    • How To Fix: PowerBI Query Editor “Cannot modify this step because there are errors in previous steps” May 20, 2021
    • How to stop your torrent client spending BitTorrent Tokens (BTT) February 17, 2021

    King Tools for KOA

    King Tools for KOA

    Get it on Google Play

    Outlast: Asteroid Defense

    Outlast: Asteroid Defense

    Get it on Google Play
    © 2022 AngelofDev.com | Powered by Minimalist Blog WordPress Theme