Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of


Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Frame a slide with a rectangle


You want to "frame" a slide or slides with a rectangle.


The FrameASlide subroutine below will add a rectangle of the line thickness you request to a single slide.
The other Subroutines call it to do their work, either on the current slide or on all slides in the current presentation.

Sub CurrentSlide()
   ' This subroutine calls FrameASlide and passes it
   ' the current active slide.
    Call FrameASlide(ActiveWindow.Selection.SlideRange(1))
End Sub

Sub AllSlides()
   ' This calls FrameASlide for each slide in the presentation
   Dim oSld as Slide
   For Each oSld in ActivePresentation.Slides
      Call FrameASlide(oSld)
End Sub

Sub FrameASlide(oSld as Slide)

    Dim sngLinewidth As Single
    Dim oFrameShape As Shape
    Dim sngSlidewidth As Single
    Dim sngSlideheight As Single
    Dim oSld As Slide
    Dim sngOffset As Single

    ' EDIT:
    sngLinewidth = 2    ' frame outline thickness in points

    sngOffset = sngLinewidth / 2

    With ActivePresentation.PageSetup
        sngSlidewidth = .Slidewidth
        sngSlideheight = .Slideheight
    End With

    With oSld
        Set oFrameShape = .Shapes.AddShape(msoShapeRectangle, _
            0 + sngOffset, _
            0 + sngOffset, _
             sngSlidewidth - sngOffset, _
             sngSlideheight - sngOffset)
    End With

    With oFrameShape
        With .Line
            .Weight = sngLinewidth
            .ForeColor.RGB = RGB(0, 0, 0)   ' black
        End With
        With .Fill
            .Visible = msoFalse
        End With
    End With

End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.

Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Frame a slide with a rectangle
Last update 07 June, 2011