Spacing before signatures

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Spacing before signatures

Post by ChrisGreaves »

The documents bear a signature on page 2 of a 4-page document, and we wanted to maximize the amount of white space before the signature, by pushing the signature to the foot of the signature page.
Place the cursor in the signature (2nd-last paragraph of page 2) and run the macro.

Code: Select all

Sub SpaceBefore()
    ' Increase paragraph-spacing-before the first Paragraph of the selection to fill up the current page of the document
    Dim prg As Paragraph
    Set prg = Selection.Paragraphs(1)
    Dim lngSpaceAbove As Long
    lngSpaceAbove = prg.SpaceBefore
    Dim lngPages As Long
    lngPages = prg.Parent.Range.Information(wdActiveEndPageNumber)
    While lngPages = prg.Parent.Range.Information(wdActiveEndPageNumber)
        lngSpaceAbove = lngSpaceAbove + 1
        prg.SpaceBefore = lngSpaceAbove
    Wend
    prg.SpaceBefore = lngSpaceAbove - 1
End Sub
5.png
You do not have the required permissions to view the files attached to this post.
Last edited by ChrisGreaves on 25 May 2011, 16:48, edited 1 time in total.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Spacing before signatures

Post by ChrisGreaves »

Minutes later I decided to add some text to the document, pushing the signature paragraph over to page 3, so ...

Place the cursor in the signature (2nd-last paragraph of page 2) and run the macro.

Code: Select all

Sub DecreaseSpaceBefore()
    ' Decrease paragraph-spacing-before the first Paragraph of the selection to pull the current page up by one page.
    ' Use thids after inserting extra text after running "IncreaseSpaceBefore"
    Dim prg As Paragraph
    Set prg = Selection.Paragraphs(1)
    Dim lngSpaceAbove As Long
    lngSpaceAbove = prg.SpaceBefore
    Dim lngPages As Long
    lngPages = prg.Parent.Range.Information(wdActiveEndPageNumber)
    While lngPages = prg.Parent.Range.Information(wdActiveEndPageNumber)
        lngSpaceAbove = lngSpaceAbove - 1
        prg.SpaceBefore = lngSpaceAbove
    Wend
End Sub
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Spacing before signatures

Post by ChrisGreaves »

(later)
Edited both macros to read " ... prg.Parent.Range.Information ...".
It's the total number of pages in the document I want to keep constant, not the page number on which the signature sits.
Sorry about that ...
He who plants a seed, plants life.

User avatar
Guessed
2StarLounger
Posts: 102
Joined: 04 Feb 2010, 22:44
Location: Melbourne Australia

Re: Spacing before signatures

Post by Guessed »

I would do this by placing the signature block in a floating frame that is set to align with the bottom of the page but anchored in the last paragraph. This way it will always be in the right position and you won't need code to continually run.
Andrew Lockton
Melbourne Australia

User avatar
StuartR
Administrator
Posts: 12618
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Spacing before signatures

Post by StuartR »

I would do this by placing the signature block in the footer, with an { IF } field that ensures it only displays on the last page.
StuartR