Consulting

Results 1 to 6 of 6

Thread: help with creating word macro

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    4
    Location

    help with creating word macro

    Hi,
    I have a word template that users click on to create documents. The template has a predefined set of headers, footers, tables and fonts. The margins are set to 1 inch on the left and 2 inches on the right.
    Is there some macro/ VBA code i can put into the document such that when the document extends to the seconds page the size of the right marign changes automatically from 2 inches to 1 inch.
    thanks

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Margins are tied to Sections. If there is no Section break, then the second page will have the same margins as the first page. The issue is:

    "when the document extends to the seconds page "

    Extends how? Just by putting content in? If so, then the answer is no, not unless you use some way to determine that it has made a second page, and then go BACK and put in a Section break.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    The simple workaround for this is to draw a rectangle where you want the border in the First Page header, format the shape border to No Line so that it is invisible, and Layout to Tight as per this example.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    VERY cute Malcolm. I will add that one to my store of interesting tricks. I have never thought of doing that for margin purposes. I have learned something. Good one.

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Gerry,
    I wish I could take credit, but I think it came from a MVP website. We use headed paper with a band down the right side, so this method is used on all our letter templates.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Ive used that MVP site numorous times, works well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •