Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update margins in templates for a directory (Word 2002 (XP) Office 10)

    We have an application which uses Word templates to instantiate documents which are then merged and printed to file (eprint). In an effort to troubleshoot printing discrepancies (a 2 page Word doc becomes 3 pages when eprinted) we're looking at the template margins. In order to standardize these values, how would you do this programmatically? I apologize in advance if this is a duplicate posting, as I'm sure it is a common issue, but my search turned up nothing. So just posting the link will be great.
    Thanks

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Update margins in templates for a directory (W

    If everyone uses the same templates to create the document and the same printer drivers to generate them, they really should match...

    As for changing the margins inside a template, as with any kind of document, I believe you would have to open each one, make the change, and save and close it. Is that the solution you're looking for, or one that operates in real time when the user creates the merge document?

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update margins in templates for a directory (W

    Not really. There are hundreds of templates in question here. That would take forever. I was thinking that I could run a script that would use a directory as a target and do a "for each" statement and programmatically set the margins to a specific value. Speaking of printer, isn't it the driver of the printer that sets the last margins value?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update margins in templates for a directory (W

    You can use the following macro as starting point:

    Sub FixMargins()
    ' Modify as needed, but keep trailing backslash
    Const strPath = "C:Word"
    Dim strFile As String
    Dim doc As Document
    Application.ScreenUpdating = False
    strFile = Dir(strPath & "*.dot")
    Do While Not strFile = ""
    Set doc = Documents.Open(strPath & strFile)
    With doc.PageSetup
    .LeftMargin = InchesToPoints(1)
    .RightMargin = InchesToPoints(0.75)
    .TopMargin = InchesToPoints(0.5)
    .BottomMargin = InchesToPoints(1.25)
    End With
    doc.Close SaveChanges:=True
    strFile = Dir
    Loop
    Application.ScreenUpdating = True
    End Sub

    Note: the printer driver doesn't set the bottom margin. It sets the minimum value for each margin according to the non-printable area of the page.

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update margins in templates for a directory (Word 2002 (XP) Office 10)

    This is often the case if a document is printed to a different printer then the one used by the author. You can prevent that by going to Tools | Options, Compatibility tab, and clearing the checkbox in front of "Use printer metrics". (Or something like that; I have a Dutch version.)

Posting Permissions

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