Announcement

Collapse
No announcement yet.

Border Around Each Printed Page

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Border Around Each Printed Page



    Is there any way to force a border to be printed around the printed area (like PowerPoint's print function, for example)? If not, I can obviously enclose the entire print are in a simple line border, but this doesn't show a border at page breaks.

    If not, is there a way, or can anyone provide a macro or other way to do so, to draw a border at every hard page break (soft breaks are OK too, but not required). That is, to force a border line at the page break so the resulting format has a border around the printed information on each page.

    Many thanks.

  • #2
    Re: Border Around Each Printed Page

    This should draw borders around pages.


    Sub BorderPages()

    Dim rngBorder As Range
    Dim lngLastRow As Long
    Dim lngLastCol As Long
    Dim lngHPBreak As Long
    Dim lngVPBreak As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim rngAC As Range

    With ActiveSheet
    Set rngAC = ActiveCell
    lngLastRow = .UsedRange.Cells(.UsedRange.Rows.Count, 1).Row
    lngLastCol = .UsedRange.Cells(1, .UsedRange.Columns.Count).Offset(1, 0).Column
    .Cells(lngLastRow + 1, 1).Activate

    lngRow = 1
    For lngVPBreak = 1 To .VPageBreaks.Count
    lngCol = 1
    For lngHPBreak = 1 To .HPageBreaks.Count
    Set rngBorder = .Range(.Cells(lngRow, lngCol), _
    .Cells(.HPageBreaks(lngHPBreak).Location.Row - 1, .VPageBreaks(lngVPBreak).Location.Column - 1))
    rngBorder.BorderAround xlContinuous, xlThick
    lngRow = .HPageBreaks(lngHPBreak).Location.Row
    Next

    Set rngBorder = .Range(.Cells(lngRow, lngCol), .Cells(lngLastRow, .VPageBreaks(lngVPBreak).Location.Column - 1))
    rngBorder.BorderAround xlContinuous, xlThick

    lngCol = .VPageBreaks(lngVPBreak).Location.Column
    Next
    lngRow = 1
    For lngHPBreak = 1 To .HPageBreaks.Count
    Set rngBorder = .Range(.Cells(lngRow, lngCol), _
    .Cells(.HPageBreaks(lngHPBreak).Location.Row - 1, lngLastCol))
    rngBorder.BorderAround xlContinuous, xlThick
    lngRow = .HPageBreaks(lngHPBreak).Location.Row
    Next
    Set rngBorder = .Range(.Cells(lngRow, lngCol), .Cells(lngLastRow, lngLastCol))
    rngBorder.BorderAround xlContinuous, xlThick
    rngAC.Activate
    End With

    End Sub

    Cheers
    Andy

    Comment


    • #3


      Re: Border Around Each Printed Page

      Nice!

      Comment

      Working...
      X